| 1 |
/* Test macro expansions in <stdbool.h> in C11. */ |
| 2 |
/* { dg-do run } */ |
| 3 |
/* { dg-options "-std=c11 -pedantic-errors" } */ |
| 4 |
|
| 5 |
#include <stdbool.h> |
| 6 |
|
| 7 |
#define str(x) xstr(x) |
| 8 |
#define xstr(x) #x |
| 9 |
|
| 10 |
extern void abort (void); |
| 11 |
extern void exit (int); |
| 12 |
extern int strcmp (const char *, const char *); |
| 13 |
|
| 14 |
#if false - 1 >= 0 |
| 15 |
#error "false unsigned in #if" |
| 16 |
#endif |
| 17 |
|
| 18 |
#if false != 0 |
| 19 |
#error "false not 0 in #if" |
| 20 |
#endif |
| 21 |
|
| 22 |
#if true - 2 >= 0 |
| 23 |
#error "true unsigned in #if" |
| 24 |
#endif |
| 25 |
|
| 26 |
#if true != 1 |
| 27 |
#error "true not 1 in #if" |
| 28 |
#endif |
| 29 |
|
| 30 |
int |
| 31 |
main (void) |
| 32 |
{ |
| 33 |
if (strcmp (str (bool), "_Bool") != 0) |
| 34 |
abort (); |
| 35 |
if (_Generic (true, int : 1) != 1) |
| 36 |
abort (); |
| 37 |
if (true != 1) |
| 38 |
abort (); |
| 39 |
if (strcmp (str (true), "1") != 0) |
| 40 |
abort (); |
| 41 |
if (_Generic (false, int : 1) != 1) |
| 42 |
abort (); |
| 43 |
if (false != 0) |
| 44 |
abort (); |
| 45 |
if (strcmp (str (false), "0") != 0) |
| 46 |
abort (); |
| 47 |
if (strcmp (str (__bool_true_false_are_defined), "1") != 0) |
| 48 |
abort (); |
| 49 |
exit (0); |
| 50 |
} |