Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Sema / fp-eval-pragma-with-float-double_t-3.c
blob8be5c5535af39d8982b73f5bc3231935ea0b21a2
1 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -DNOERROR %s
2 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
3 // RUN: -x c++ -DCPP -DNOERROR %s
5 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
6 // RUN: -ffp-eval-method=extended -DNOERROR %s
7 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
8 // RUN: -ffp-eval-method=extended -DNOERROR %s
10 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
11 // RUN: -ffp-eval-method=source %s
12 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
13 // RUN: -ffp-eval-method=source %s
15 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
16 // RUN: -ffp-eval-method=double %s
17 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
18 // RUN: -ffp-eval-method=double %s
21 #ifdef NOERROR
22 // expected-no-diagnostics
23 typedef float float_t;
24 typedef double double_t;
25 #else
26 #ifdef CPP
27 typedef float float_t; //expected-error 9 {{cannot use type 'float_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}
29 typedef double double_t; //expected-error 9 {{cannot use type 'double_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}
30 #else
31 typedef float float_t; //expected-error 7 {{cannot use type 'float_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}
33 typedef double double_t; //expected-error 7 {{cannot use type 'double_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}
34 #endif
35 #endif
37 float foo1() {
38 #pragma clang fp eval_method(extended)
39 float a;
40 double b;
41 return a - b;
44 float foo2() {
45 #pragma clang fp eval_method(extended)
46 float_t a;
47 double_t b;
48 return a - b;
51 void foo3() {
52 #pragma clang fp eval_method(extended)
53 char buff[sizeof(float_t)];
54 char bufd[sizeof(double_t)];
55 buff[1] = bufd[2];
58 float foo4() {
59 #pragma clang fp eval_method(extended)
60 typedef float_t FT;
61 typedef double_t DT;
62 FT a;
63 DT b;
64 return a - b;
67 int foo5() {
68 #pragma clang fp eval_method(extended)
69 int t = _Generic( 1.0L, float_t:1, default:0);
70 int v = _Generic( 1.0L, double_t:1, default:0);
71 return t;
74 void foo6() {
75 #pragma clang fp eval_method(extended)
76 float f = (float_t)1;
77 double d = (double_t)2;
80 void foo7() {
81 #pragma clang fp eval_method(extended)
82 float c1 = (float_t)12;
83 double c2 = (double_t)13;
86 float foo8() {
87 #pragma clang fp eval_method(extended)
88 extern float_t f;
89 extern double_t g;
90 return f-g;
93 #ifdef CPP
94 void foo9() {
95 #pragma clang fp eval_method(extended)
96 auto resf = [](float_t f) { return f; };
97 auto resd = [](double_t g) { return g; };
100 void foo10() {
101 #pragma clang fp eval_method(extended)
102 using Ft = float_t;
103 using Dt = double_t;
104 Ft a;
105 Dt b;
107 #endif