c: New C2x keywords
[platform/upstream/gcc.git] / gcc / testsuite / gcc.dg / c2x-bool-2.c
1 /* Test bool, true and false keywords in C2x.  */
2 /* { dg-do run } */
3 /* { dg-options "-std=c2x -pedantic-errors" } */
4
5 extern void abort (void);
6 extern void exit (int);
7
8 #if false - 1 >= 0
9 #error "false unsigned in #if"
10 #endif
11
12 #if false != 0
13 #error "false not 0 in #if"
14 #endif
15
16 #if true - 2 >= 0
17 #error "true unsigned in #if"
18 #endif
19
20 #if true != 1
21 #error "true not 1 in #if"
22 #endif
23
24 extern bool b;
25 extern _Bool b;
26
27 _Static_assert (false == 0);
28 _Static_assert (true == 1);
29
30 int
31 main (void)
32 {
33   if (_Generic (true, bool : 1) != 1)
34     abort ();
35   if (true != 1)
36     abort ();
37   if (_Generic (false, bool : 1) != 1)
38     abort ();
39   if (false != 0)
40     abort ();
41   exit (0);
42 }