Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / gcc / testsuite / gcc.dg / dfp / pragma-float-const-decimal64-1.c
blob62d85b6d349bb0092d7b0dc10ec841f37aa25777
1 /* { dg-do compile } */
2 /* { dg-options "-Wall" } */
4 /* N1312 7.1.1: The FLOAT_CONST_DECIMAL64 pragma.
5 C99 6.4.4.2a (New).
7 Verify that the pragma has the expected result by using unsuffixed
8 float constants as operands in expressions that would mix binary and
9 decimal operands if the pragma had no effect, or the wrong effect. */
11 #pragma STDC FLOAT_CONST_DECIMAL64 ON
12 double a = 1.0 * 2.0dd;
14 double
15 f1 (void)
17 #pragma STDC FLOAT_CONST_DECIMAL64 OFF
18 double b = 2.0 * 3.0d;
21 double c = 3.0 * 4.0d;
22 b = b + c;
26 #pragma STDC FLOAT_CONST_DECIMAL64 ON
27 double d = 4.0 * 5.0dd;
29 b = b + d;
33 /* Default is OFF. */
34 #pragma STDC FLOAT_CONST_DECIMAL64 DEFAULT
35 double e = 5.0 * 6.0d;
36 b = b + e;
39 return b;
42 double
43 f2 (void)
45 /* Use value from outer scope, which is ON. */
46 double b = 2.0 * 3.0dd;
49 #pragma STDC FLOAT_CONST_DECIMAL64 OFF
50 double c = 3.0 * 4.0d;
53 #pragma STDC FLOAT_CONST_DECIMAL64 ON
54 double d = 4.0 * 5.0dd;
57 #pragma STDC FLOAT_CONST_DECIMAL64 DEFAULT
58 double e = 5.0 * 6.0d;
61 #pragma STDC FLOAT_CONST_DECIMAL64 ON
62 double f = 6.0 * 7.0dd;
64 b = a + b + c + d + e + f;
69 return b;
72 /* Use previous value from this scope, which is ON. */
73 double f = 6.0 * 7.0dd;
75 double
76 f3 (void)
78 #pragma STDC FLOAT_CONST_DECIMAL64 OFF
79 double b = 2.0 * 3.0d;
81 return b + f;
84 /* Return to the state from this scope, which is ON. */
85 double g = 7.0 + 8.0dd;