| 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 |
// Ok, at namespace scope. |
| 9 |
namespace foo { |
| 10 |
#pragma float_control(push) |
| 11 |
#pragma float_control(pop) |
| 12 |
} |
| 13 |
|
| 14 |
// Ok, within a language linkage specification. |
| 15 |
extern "C" { |
| 16 |
#pragma float_control(push) |
| 17 |
#pragma float_control(pop) |
| 18 |
} |
| 19 |
|
| 20 |
// Same. |
| 21 |
extern "C++" { |
| 22 |
#pragma float_control(push) |
| 23 |
#pragma float_control(pop) |
| 24 |
} |
| 25 |
|
| 26 |
#ifdef CHECK_ERROR |
| 27 |
// Ok at file scope. |
| 28 |
#pragma float_control(push) |
| 29 |
#pragma float_control(pop) |
| 30 |
#pragma float_control(precise, on, push) |
| 31 |
void check_stack() { |
| 32 |
// Not okay within a function declaration. |
| 33 |
#pragma float_control(push) // expected-error {{can only appear at file or namespace scope or within a language linkage specification}} |
| 34 |
#pragma float_control(pop) // expected-error {{can only appear at file or namespace scope or within a language linkage specification}} |
| 35 |
#pragma float_control(precise, on, push) // expected-error {{can only appear at file or namespace scope or within a language linkage specification}} |
| 36 |
#pragma float_control(except, on, push) // expected-error {{can only appear at file or namespace scope or within a language linkage specification}} |
| 37 |
#pragma float_control(except, on, push, junk) // expected-error {{float_control is malformed}} |
| 38 |
return; |
| 39 |
} |
| 40 |
#endif |
| 41 |
|
| 42 |
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fdenormal-fp-math=preserve-sign,preserve-sign -fsyntax-only %s -DDEFAULT -verify |
| 43 |
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only %s -ffp-contract=fast -DPRECISE -verify |
| 44 |
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only %s -ffp-contract=off -frounding-math -ffp-exception-behavior=strict -DSTRICT -verify |
| 45 |
// RUN: %clang_cc1 -triple x86_64-linux-gnu -menable-no-infs -menable-no-nans -funsafe-math-optimizations -fno-signed-zeros -mreassociate -freciprocal-math -ffp-contract=fast -ffast-math -ffinite-math-only -fsyntax-only %s -DFAST -verify |
| 46 |
double a = 0.0; |
| 47 |
double b = 1.0; |
| 48 |
|
| 49 |
#ifdef STRICT |
| 50 |
#pragma float_control(precise, off) // expected-error {{'#pragma float_control(precise, off)' is illegal when except is enabled}} |
| 51 |
#else |
| 52 |
#ifndef FAST |
| 53 |
#pragma STDC FENV_ACCESS ON |
| 54 |
#pragma float_control(precise, off) // expected-error {{'#pragma float_control(precise, off)' is illegal when except is enabled}} |
| 55 |
#endif |
| 56 |
#endif |
| 57 |
|
| 58 |
#pragma float_control(precise, on) |
| 59 |
#pragma float_control(except, on) // OK |
| 60 |
#ifndef STRICT |
| 61 |
#pragma float_control(except, on) |
| 62 |
#pragma float_control(precise, off) // expected-error {{'#pragma float_control(precise, off)' is illegal when except is enabled}} |
| 63 |
#endif |
| 64 |
int main() { |
| 65 |
#ifdef STRICT |
| 66 |
#pragma float_control(precise, off) // expected-error {{'#pragma float_control(precise, off)' is illegal when except is enabled}} |
| 67 |
#else |
| 68 |
#pragma float_control(precise, off) // expected-error {{'#pragma float_control(precise, off)' is illegal when except is enabled}} |
| 69 |
#endif |
| 70 |
#pragma float_control(except, on) |
| 71 |
// error: '#pragma float_control(except, on)' is illegal when precise is disabled |
| 72 |
double x = b / a; // only used for fp flag setting |
| 73 |
if (a == a) // only used for fp flag setting |
| 74 |
return 0; //(int)x; |
| 75 |
} |