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 #ifdef STRICT 30 #pragma float_control(precise, off) // expected-error {{'#pragma float_control(precise, off)' is illegal when except is enabled}} 31 #else 32 #ifndef FAST 33 #pragma STDC FENV_ACCESS ON 34 #pragma float_control(precise, off) // expected-error {{'#pragma float_control(precise, off)' is illegal when except is enabled}} 35 #endif 36 #endif 37 38 #pragma float_control(precise, on) 39 #pragma float_control(except, on) // OK 40 #ifndef STRICT 41 #pragma float_control(except, on) 42 #pragma float_control(precise, off) // expected-error {{'#pragma float_control(precise, off)' is illegal when except is enabled}} 43 #endif 44 int main() { 45 #ifdef STRICT 46 #pragma float_control(precise, off) // expected-error {{'#pragma float_control(precise, off)' is illegal when except is enabled}} 47 #else 48 #pragma float_control(precise, off) // expected-error {{'#pragma float_control(precise, off)' is illegal when except is enabled}} 49 #endif 50 #pragma float_control(except, on) 51 // error: '#pragma float_control(except, on)' is illegal when precise is disabled 52 double x = b / a; // only used for fp flag setting 53 if (a == a) // only used for fp flag setting 54 return 0; //(int)x; 55 } 56