1 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -DCHECK_ERROR %s -verify
2 
3 float function_scope(float a) {
4 #pragma float_control(precise, on) junk // expected-warning {{extra tokens at end of '#pragma float_control' - ignored}}
5   return a;
6 }
7 
8 #ifdef CHECK_ERROR
9 #pragma float_control(push)
10 #pragma float_control(pop)
11 #pragma float_control(precise, on, push)
12 void check_stack() {
13 #pragma float_control(push)                   // expected-error {{can only appear at file scope or namespace scope}}
14 #pragma float_control(pop)                    // expected-error {{can only appear at file scope or namespace scope}}
15 #pragma float_control(precise, on, push)      // expected-error {{can only appear at file scope or namespace scope}}
16 #pragma float_control(except, on, push)       // expected-error {{can only appear at file scope or namespace scope}}
17 #pragma float_control(except, on, push, junk) // expected-error {{float_control is malformed}}
18   return;
19 }
20 #endif
21 
22 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fdenormal-fp-math=preserve-sign,preserve-sign -ftrapping-math -fsyntax-only %s -DDEFAULT -verify
23 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only %s -ffp-contract=fast -DPRECISE -verify
24 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only %s -ftrapping-math -ffp-contract=off -frounding-math -ffp-exception-behavior=strict -DSTRICT -verify
25 // RUN: %clang_cc1 -triple x86_64-linux-gnu -menable-no-infs -menable-no-nans -menable-unsafe-fp-math -fno-signed-zeros -mreassociate -freciprocal-math -ffp-contract=fast -ffast-math -ffinite-math-only -fsyntax-only %s -DFAST -verify
26 double a = 0.0;
27 double b = 1.0;
28 
29 //FIXME At some point this warning will be removed, until then
30 //      document the warning
31 #ifdef FAST
32 // expected-warning@+1{{pragma STDC FENV_ACCESS ON is not supported, ignoring pragma}}
33 #pragma STDC FENV_ACCESS ON
34 #else
35 #pragma STDC FENV_ACCESS ON // expected-warning{{pragma STDC FENV_ACCESS ON is not supported, ignoring pragma}}
36 #endif
37 #ifdef STRICT
38 #pragma float_control(precise, off) // expected-error {{'#pragma float_control(precise, off)' is illegal when except is enabled}}
39 #else
40 // Currently FENV_ACCESS cannot be enabled by pragma, skip error check
41 #pragma float_control(precise, off) // not-expected-error {{'#pragma float_control(precise, off)' is illegal when fenv_access is enabled}}
42 #endif
43 
44 #pragma float_control(precise, on)
45 #pragma float_control(except, on) // OK
46 #ifndef STRICT
47 #pragma float_control(except, on)
48 #pragma float_control(precise, off) // expected-error {{'#pragma float_control(precise, off)' is illegal when except is enabled}}
49 #endif
50 int main() {
51 #ifdef STRICT
52 #pragma float_control(precise, off) // expected-error {{'#pragma float_control(precise, off)' is illegal when except is enabled}}
53 #else
54 #pragma float_control(precise, off) // expected-error {{'#pragma float_control(precise, off)' is illegal when except is enabled}}
55 #endif
56 #pragma float_control(except, on)
57   //  error: '#pragma float_control(except, on)' is illegal when precise is disabled
58   double x = b / a; // only used for fp flag setting
59   if (a == a)       // only used for fp flag setting
60     return 0;       //(int)x;
61 }
62