Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Sema / fp-eval-pragma-with-float-double_t-2.c
blob61bf7c970807cbc055c125970a858da873e9146c
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=double -DNOERROR %s
7 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
8 // RUN: -ffp-eval-method=double -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=extended %s
17 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
18 // RUN: -ffp-eval-method=extended %s
20 #ifdef NOERROR
21 // expected-no-diagnostics
22 typedef float float_t;
23 typedef double double_t;
24 #else
25 #ifdef CPP
26 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}}
28 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}}
29 #else
30 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}}
32 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}}
33 #endif
34 #endif
36 float foo1() {
37 #pragma clang fp eval_method(double)
38 float a;
39 double b;
40 return a - b;
43 float foo2() {
44 #pragma clang fp eval_method(double)
45 float_t a;
46 double_t b;
47 return a - b;
50 void foo3() {
51 #pragma clang fp eval_method(double)
52 char buff[sizeof(float_t)];
53 char bufd[sizeof(double_t)];
54 buff[1] = bufd[2];
57 float foo4() {
58 #pragma clang fp eval_method(double)
59 typedef float_t FT;
60 typedef double_t DT;
61 FT a;
62 DT b;
63 return a - b;
66 int foo5() {
67 #pragma clang fp eval_method(double)
68 int t = _Generic( 1.0L, float_t:1, default:0);
69 int v = _Generic( 1.0L, double_t:1, default:0);
70 return t;
73 void foo6() {
74 #pragma clang fp eval_method(double)
75 float f = (float_t)1;
76 double d = (double_t)2;
79 void foo7() {
80 #pragma clang fp eval_method(double)
81 float c1 = (float_t)12;
82 double c2 = (double_t)13;
85 float foo8() {
86 #pragma clang fp eval_method(double)
87 extern float_t f;
88 extern double_t g;
89 return f-g;
92 #ifdef CPP
93 void foo9() {
94 #pragma clang fp eval_method(double)
95 auto resf = [](float_t f) { return f; };
96 auto resd = [](double_t g) { return g; };
99 void foo10() {
100 #pragma clang fp eval_method(double)
101 using Ft = float_t;
102 using Dt = double_t;
103 Ft a;
104 Dt b;
106 #endif