summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/dfp/pragma-float-const-decimal64-3.c
blob: 195998670356aebf7bf8ea14e29037c25f1b9eac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* { dg-do compile } */
/* { dg-options "-Wall" } */

/* N1312 7.1.1: The FLOAT_CONST_DECIMAL64 pragma.
   C99 6.4.4.2a (New).  */

/* Check that defining macros whose names are the same as the tokens used
   in the pragma doesn't affect use of the pragma.  */

#define ON YES
#define OFF NO
#define DEFAULT NOPE
#define STDC OFFICIAL
#define FLOAT_CONST_DECIMAL64 NEW_PRAGMA

double a;

void
f1a (void)
{
#pragma STDC FLOAT_CONST_DECIMAL64 ON
  a = 1.0dd + 2.0;
}

void
f1b (void)
{
#pragma STDC FLOAT_CONST_DECIMAL64 OFF
  a = 2.0d + 3.0;
}

void
f1c (void)
{
#pragma STDC FLOAT_CONST_DECIMAL64 DEFAULT
  a = 3.0d + 4.0;
}

/* Check that a macro can be used for the entire pragma.  */

#define PRAGMA(x) _Pragma (#x)
#define DEFAULT_FLOAT_IS_DECIMAL PRAGMA(STDC FLOAT_CONST_DECIMAL64 ON)
#define DEFAULT_FLOAT_IS_BINARY PRAGMA(STDC FLOAT_CONST_DECIMAL64 OFF)

void
f2a (void)
{
  DEFAULT_FLOAT_IS_DECIMAL
  a = 5.0 * 6.0dd;
}

void
f2b (void)
{
  DEFAULT_FLOAT_IS_BINARY
  a = 6.0 * 7.0d;
}

/* _Pragma can be used with macros, including the use of a macro for the
    switch.  */

#undef ON
#undef OFF
#undef DEFAULT
#undef STDC
#undef FLOAT_CONST_DECIMAL64

#define SWITCH ON
#define FLOAT_CONST_DECIMAL64(x) PRAGMA(STDC FLOAT_CONST_DECIMAL64 x)

void
f3a (void)
{
  FLOAT_CONST_DECIMAL64(SWITCH)
  a = 1.0 * 7.0dd;
}

void
f3b (void)
{
  FLOAT_CONST_DECIMAL64(OFF)
  a = 1.0 + 2.0d;
}