OSDN Git Service

2012-01-30 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / dfp / pragma-float-const-decimal64-2.c
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    Use _Pragma rather than #pragma.  */
11
12 _Pragma ("STDC FLOAT_CONST_DECIMAL64 ON")
13 double a = 1.0 * 2.0dd;
14
15 double
16 f1 (void)
17 {
18 _Pragma ("STDC FLOAT_CONST_DECIMAL64 OFF")
19   double b = 2.0 * 3.0d;
20
21   {
22     double c = 3.0 * 4.0d;
23     b = b + c;
24   }
25
26   {
27 _Pragma ("STDC FLOAT_CONST_DECIMAL64 ON")
28     double d = 4.0 * 5.0dd;
29
30     b = b + d;
31   }
32
33   {
34      /* Default is OFF.  */
35 _Pragma ("STDC FLOAT_CONST_DECIMAL64 DEFAULT")
36      double e = 5.0 * 6.0d;
37      b = b + e;
38   }
39
40   return b;
41 }
42
43 double
44 f2 (void)
45 {
46   /* Use value from outer scope, which is ON.  */
47   double b = 2.0 * 3.0dd;
48
49   {
50 _Pragma ("STDC FLOAT_CONST_DECIMAL64 OFF")
51     double c = 3.0 * 4.0d;
52
53     {
54 _Pragma ("STDC FLOAT_CONST_DECIMAL64 ON")
55       double d = 4.0 * 5.0dd;
56
57       {
58 _Pragma ("STDC FLOAT_CONST_DECIMAL64 DEFAULT")
59         double e = 5.0 * 6.0d;
60
61         {
62 _Pragma ("STDC FLOAT_CONST_DECIMAL64 ON")
63           double f = 6.0 * 7.0dd;
64
65           b = a + b + c + d + e + f;
66         }
67       }
68     }
69   }
70   return b;
71 }
72
73 /* Use previous value from this scope, which is ON.  */
74 double f = 6.0 * 7.0dd;
75
76 double
77 f3 (void)
78 {
79 _Pragma ("STDC FLOAT_CONST_DECIMAL64 OFF")
80   double b = 2.0 * 3.0d;
81
82   return b + f;
83 }
84
85 /* Return to the state from this scope, which is ON.  */
86 double g = 7.0 + 8.0dd;