Debian Codegraph @

gcc/testsuite/gcc.dg/dfp/pragma-float-const-decimal64-1.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-Wall" } */
3
4 /* N1312 7.1.1: The FLOAT_CONST_DECIMAL64 pragma.
5 C99 6.4.4.2a (New).
6
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. */
10
11 #pragma STDC FLOAT_CONST_DECIMAL64 ON
12 double a = 1.0 * 2.0dd;
13
14 double
15 f1 (void)
16 {
17 #pragma STDC FLOAT_CONST_DECIMAL64 OFF
18 double b = 2.0 * 3.0d;
19
20 {
21 double c = 3.0 * 4.0d;
22 b = b + c;
23 }
24
25 {
26 #pragma STDC FLOAT_CONST_DECIMAL64 ON
27 double d = 4.0 * 5.0dd;
28
29 b = b + d;
30 }
31
32 {
33 /* Default is OFF. */
34 #pragma STDC FLOAT_CONST_DECIMAL64 DEFAULT
35 double e = 5.0 * 6.0d;
36 b = b + e;
37 }
38
39 return b;
40 }
41
42 double
43 f2 (void)
44 {
45 /* Use value from outer scope, which is ON. */
46 double b = 2.0 * 3.0dd;
47
48 {
49 #pragma STDC FLOAT_CONST_DECIMAL64 OFF
50 double c = 3.0 * 4.0d;
51
52 {
53 #pragma STDC FLOAT_CONST_DECIMAL64 ON
54 double d = 4.0 * 5.0dd;
55
56 {
57 #pragma STDC FLOAT_CONST_DECIMAL64 DEFAULT
58 double e = 5.0 * 6.0d;
59
60 {
61 #pragma STDC FLOAT_CONST_DECIMAL64 ON
62 double f = 6.0 * 7.0dd;
63
64 b = a + b + c + d + e + f;
65 }
66 }
67 }
68 }
69 return b;
70 }
71
72 /* Use previous value from this scope, which is ON. */
73 double f = 6.0 * 7.0dd;
74
75 double
76 f3 (void)
77 {
78 #pragma STDC FLOAT_CONST_DECIMAL64 OFF
79 double b = 2.0 * 3.0d;
80
81 return b + f;
82 }
83
84 /* Return to the state from this scope, which is ON. */
85 double g = 7.0 + 8.0dd;