aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/c2x-bool-2.c
blob: 4edb34e4de9273f1f2148b038bfab2a43d537980 (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
/* Test bool, true and false keywords in C2x.  */
/* { dg-do run } */
/* { dg-options "-std=c2x -pedantic-errors" } */

extern void abort (void);
extern void exit (int);

#if false - 1 >= 0
#error "false unsigned in #if"
#endif

#if false != 0
#error "false not 0 in #if"
#endif

#if true - 2 >= 0
#error "true unsigned in #if"
#endif

#if true != 1
#error "true not 1 in #if"
#endif

extern bool b;
extern _Bool b;

_Static_assert (false == 0);
_Static_assert (true == 1);

int
main (void)
{
  if (_Generic (true, bool : 1) != 1)
    abort ();
  if (true != 1)
    abort ();
  if (_Generic (false, bool : 1) != 1)
    abort ();
  if (false != 0)
    abort ();
  exit (0);
}