[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Sema / fp-eval-pragma.cpp
blob571b8097e9abf8a16c30cbc98cb3f2cc2f70efcc
1 // RUN: %clang_cc1 -fexperimental-strict-floating-point \
2 // RUN: -triple x86_64-linux-gnu -emit-llvm -o - -verify %s
3 //
4 // RUN: %clang_cc1 -fexperimental-strict-floating-point \
5 // RUN: -triple x86_64-linux-gnu -emit-llvm -o - -verify %s \
6 // RUN: -ffp-eval-method=source
7 //
8 // RUN: %clang_cc1 -fexperimental-strict-floating-point \
9 // RUN: -triple x86_64-linux-gnu -emit-llvm -o - -verify %s \
10 // RUN: -ffp-eval-method=double
12 extern "C" int printf(const char *, ...);
14 void foo1() {
15 printf("FP: %d\n", __FLT_EVAL_METHOD__);
18 void apply_pragma() {
19 // expected-note@+1{{#pragma entered here}}
20 #pragma clang fp eval_method(double)
21 // expected-error@+1{{'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing '#pragma clang fp eval_method'}}
22 printf("FP: %d\n", __FLT_EVAL_METHOD__);
25 int foo2() {
26 apply_pragma();
27 return 0;
30 void apply_pragma_with_wrong_value() {
31 // expected-error@+1{{unexpected argument 'value' to '#pragma clang fp eval_method'; expected 'source', 'double' or 'extended'}}
32 #pragma clang fp eval_method(value)
35 int foo3() {
36 apply_pragma_with_wrong_value();
37 return 0;
40 void foo() {
41 auto a = __FLT_EVAL_METHOD__;
43 // expected-note@+1{{#pragma entered here}}
44 #pragma clang fp eval_method(double)
45 // expected-error@+1{{'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing '#pragma clang fp eval_method'}}
46 auto b = __FLT_EVAL_METHOD__;
48 auto c = __FLT_EVAL_METHOD__;
51 void func() {
54 #pragma clang fp eval_method(source)
56 int i = __FLT_EVAL_METHOD__; // ok, not in a scope changed by the pragma
59 // expected-note@+1{{#pragma entered here}}
60 #pragma clang fp eval_method(source)
61 // expected-error@+1{{'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing '#pragma clang fp eval_method'}}
62 int i = __FLT_EVAL_METHOD__;
66 float G;
68 int f(float x, float y, float z) {
69 G = x * y + z;
70 return __FLT_EVAL_METHOD__;
73 int foo(int flag, float x, float y, float z) {
74 if (flag) {
75 // expected-note@+1{{#pragma entered here}}
76 #pragma clang fp eval_method(double)
77 G = x + y + z;
78 // expected-error@+1{{'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing '#pragma clang fp eval_method'}}
79 return __FLT_EVAL_METHOD__;
80 } else {
81 // expected-note@+1{{#pragma entered here}}
82 #pragma clang fp eval_method(extended)
83 G = x + y + z;
84 // expected-error@+1{{'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing '#pragma clang fp eval_method'}}
85 return __FLT_EVAL_METHOD__;
89 #if __FLT_EVAL_METHOD__ == 1
90 #endif
91 #pragma clang fp eval_method(source)
93 // expected-note@+1{{#pragma entered here}}
94 #pragma clang fp eval_method(double)
95 // expected-error@+1{{'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing '#pragma clang fp eval_method'}}
96 #if __FLT_EVAL_METHOD__ == 1
97 #endif