blob: 571b8097e9abf8a16c30cbc98cb3f2cc2f70efcc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
// RUN: %clang_cc1 -fexperimental-strict-floating-point \
// RUN: -triple x86_64-linux-gnu -emit-llvm -o - -verify %s
//
// RUN: %clang_cc1 -fexperimental-strict-floating-point \
// RUN: -triple x86_64-linux-gnu -emit-llvm -o - -verify %s \
// RUN: -ffp-eval-method=source
//
// RUN: %clang_cc1 -fexperimental-strict-floating-point \
// RUN: -triple x86_64-linux-gnu -emit-llvm -o - -verify %s \
// RUN: -ffp-eval-method=double
extern "C" int printf(const char *, ...);
void foo1() {
printf("FP: %d\n", __FLT_EVAL_METHOD__);
}
void apply_pragma() {
// expected-note@+1{{#pragma entered here}}
#pragma clang fp eval_method(double)
// expected-error@+1{{'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing '#pragma clang fp eval_method'}}
printf("FP: %d\n", __FLT_EVAL_METHOD__);
}
int foo2() {
apply_pragma();
return 0;
}
void apply_pragma_with_wrong_value() {
// expected-error@+1{{unexpected argument 'value' to '#pragma clang fp eval_method'; expected 'source', 'double' or 'extended'}}
#pragma clang fp eval_method(value)
}
int foo3() {
apply_pragma_with_wrong_value();
return 0;
}
void foo() {
auto a = __FLT_EVAL_METHOD__;
{
// expected-note@+1{{#pragma entered here}}
#pragma clang fp eval_method(double)
// expected-error@+1{{'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing '#pragma clang fp eval_method'}}
auto b = __FLT_EVAL_METHOD__;
}
auto c = __FLT_EVAL_METHOD__;
}
void func() {
{
{
#pragma clang fp eval_method(source)
}
int i = __FLT_EVAL_METHOD__; // ok, not in a scope changed by the pragma
}
{
// expected-note@+1{{#pragma entered here}}
#pragma clang fp eval_method(source)
// expected-error@+1{{'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing '#pragma clang fp eval_method'}}
int i = __FLT_EVAL_METHOD__;
}
}
float G;
int f(float x, float y, float z) {
G = x * y + z;
return __FLT_EVAL_METHOD__;
}
int foo(int flag, float x, float y, float z) {
if (flag) {
// expected-note@+1{{#pragma entered here}}
#pragma clang fp eval_method(double)
G = x + y + z;
// expected-error@+1{{'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing '#pragma clang fp eval_method'}}
return __FLT_EVAL_METHOD__;
} else {
// expected-note@+1{{#pragma entered here}}
#pragma clang fp eval_method(extended)
G = x + y + z;
// expected-error@+1{{'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing '#pragma clang fp eval_method'}}
return __FLT_EVAL_METHOD__;
}
}
#if __FLT_EVAL_METHOD__ == 1
#endif
#pragma clang fp eval_method(source)
// expected-note@+1{{#pragma entered here}}
#pragma clang fp eval_method(double)
// expected-error@+1{{'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing '#pragma clang fp eval_method'}}
#if __FLT_EVAL_METHOD__ == 1
#endif
|