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 -DNOERROR %s -fexperimental-new-constant-interpreter
3
4 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
5 // RUN: -x c++ -DCPP -DNOERROR %s
6 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
7 // RUN: -x c++ -DCPP -DNOERROR %s -fexperimental-new-constant-interpreter
8
9 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
10 // RUN: -ffp-eval-method=extended -DNOERROR %s
11 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
12 // RUN: -ffp-eval-method=extended -DNOERROR %s -fexperimental-new-constant-interpreter
13
14 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
15 // RUN: -ffp-eval-method=extended -DNOERROR %s
16 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
17 // RUN: -ffp-eval-method=extended -DNOERROR %s -fexperimental-new-constant-interpreter
18
19 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
20 // RUN: -ffp-eval-method=source %s
21 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
22 // RUN: -ffp-eval-method=source %s -fexperimental-new-constant-interpreter
23
24 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
25 // RUN: -ffp-eval-method=source %s
26 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
27 // RUN: -ffp-eval-method=source %s -fexperimental-new-constant-interpreter
28
29 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
30 // RUN: -ffp-eval-method=double %s
31 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
32 // RUN: -ffp-eval-method=double %s -fexperimental-new-constant-interpreter
33
34 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
35 // RUN: -ffp-eval-method=double %s
36 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
37 // RUN: -ffp-eval-method=double %s -fexperimental-new-constant-interpreter
38
39 #ifdef NOERROR
40 // expected-no-diagnostics
41 typedef float float_t;
42 typedef double double_t;
43 #else
44 #ifdef CPP
45 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}}
46
47 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}}
48 #else
49 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}}
50
51 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}}
52 #endif
53 #endif
54
foo1()55 float foo1() {
56 #pragma clang fp eval_method(extended)
57 float a;
58 double b;
59 return a - b;
60 }
61
foo2()62 float foo2() {
63 #pragma clang fp eval_method(extended)
64 float_t a;
65 double_t b;
66 return a - b;
67 }
68
foo3()69 void foo3() {
70 #pragma clang fp eval_method(extended)
71 char buff[sizeof(float_t)];
72 char bufd[sizeof(double_t)];
73 buff[1] = bufd[2];
74 }
75
foo4()76 float foo4() {
77 #pragma clang fp eval_method(extended)
78 typedef float_t FT;
79 typedef double_t DT;
80 FT a;
81 DT b;
82 return a - b;
83 }
84
foo5()85 int foo5() {
86 #pragma clang fp eval_method(extended)
87 int t = _Generic( 1.0L, float_t:1, default:0);
88 int v = _Generic( 1.0L, double_t:1, default:0);
89 return t;
90 }
91
foo6()92 void foo6() {
93 #pragma clang fp eval_method(extended)
94 float f = (float_t)1;
95 double d = (double_t)2;
96 }
97
foo7()98 void foo7() {
99 #pragma clang fp eval_method(extended)
100 float c1 = (float_t)12;
101 double c2 = (double_t)13;
102 }
103
foo8()104 float foo8() {
105 #pragma clang fp eval_method(extended)
106 extern float_t f;
107 extern double_t g;
108 return f-g;
109 }
110
111 #ifdef CPP
foo9()112 void foo9() {
113 #pragma clang fp eval_method(extended)
114 auto resf = [](float_t f) { return f; };
115 auto resd = [](double_t g) { return g; };
116 }
117
foo10()118 void foo10() {
119 #pragma clang fp eval_method(extended)
120 using Ft = float_t;
121 using Dt = double_t;
122 Ft a;
123 Dt b;
124 }
125 #endif
126
127