1 // RUN: %clang_cc1 -fexperimental-strict-floating-point \
2 // RUN: -triple x86_64-linux-gnu -emit-llvm -o - -verify %s
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
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 *, ...);
15 printf("FP: %d\n", __FLT_EVAL_METHOD__
);
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__
);
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)
36 apply_pragma_with_wrong_value();
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__
;
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__
;
68 int f(float x
, float y
, float z
) {
70 return __FLT_EVAL_METHOD__
;
73 int foo(int flag
, float x
, float y
, float z
) {
75 // expected-note@+1{{#pragma entered here}}
76 #pragma clang fp eval_method(double)
78 // expected-error@+1{{'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing '#pragma clang fp eval_method'}}
79 return __FLT_EVAL_METHOD__
;
81 // expected-note@+1{{#pragma entered here}}
82 #pragma clang fp eval_method(extended)
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
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