gcc/
[official-gcc.git] / gcc / testsuite / gcc.dg / dfp / pragma-float-const-decimal64-3.c
blobb9286aac11a9395fd6e0d5ea99efe1f222d2f749
1 /* { dg-do compile } */
2 /* { dg-options "-std=gnu99 -Wall" } */
4 /* N1312 7.1.1: The FLOAT_CONST_DECIMAL64 pragma.
5 C99 6.4.4.2a (New). */
7 /* Check that defining macros whose names are the same as the tokens used
8 in the pragma doesn't affect use of the pragma. */
10 #define ON YES
11 #define OFF NO
12 #define DEFAULT NOPE
13 #define STDC OFFICIAL
14 #define FLOAT_CONST_DECIMAL64 NEW_PRAGMA
16 double a;
18 void
19 f1a (void)
21 #pragma STDC FLOAT_CONST_DECIMAL64 ON
22 a = 1.0dd + 2.0;
25 void
26 f1b (void)
28 #pragma STDC FLOAT_CONST_DECIMAL64 OFF
29 a = 2.0d + 3.0;
32 void
33 f1c (void)
35 #pragma STDC FLOAT_CONST_DECIMAL64 DEFAULT
36 a = 3.0d + 4.0;
39 /* Check that a macro can be used for the entire pragma. */
41 #define PRAGMA(x) _Pragma (#x)
42 #define DEFAULT_FLOAT_IS_DECIMAL PRAGMA(STDC FLOAT_CONST_DECIMAL64 ON)
43 #define DEFAULT_FLOAT_IS_BINARY PRAGMA(STDC FLOAT_CONST_DECIMAL64 OFF)
45 void
46 f2a (void)
48 DEFAULT_FLOAT_IS_DECIMAL
49 a = 5.0 * 6.0dd;
52 void
53 f2b (void)
55 DEFAULT_FLOAT_IS_BINARY
56 a = 6.0 * 7.0d;
59 /* _Pragma can be used with macros, including the use of a macro for the
60 switch. */
62 #undef ON
63 #undef OFF
64 #undef DEFAULT
65 #undef STDC
66 #undef FLOAT_CONST_DECIMAL64
68 #define SWITCH ON
69 #define FLOAT_CONST_DECIMAL64(x) PRAGMA(STDC FLOAT_CONST_DECIMAL64 x)
71 void
72 f3a (void)
74 FLOAT_CONST_DECIMAL64(SWITCH)
75 a = 1.0 * 7.0dd;
78 void
79 f3b (void)
81 FLOAT_CONST_DECIMAL64(OFF)
82 a = 1.0 + 2.0d;