| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#ifndef __GNUC__ |
| 22 |
# define ADDRESS_CHECK_OKAY |
| 23 |
#elif __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3) |
| 24 |
|
| 25 |
#else |
| 26 |
# pragma GCC diagnostic ignored "-Waddress" |
| 27 |
# define ADDRESS_CHECK_OKAY |
| 28 |
#endif |
| 29 |
|
| 30 |
#include <config.h> |
| 31 |
|
| 32 |
#include <stdbool.h> |
| 33 |
|
| 34 |
#ifndef bool |
| 35 |
"error: bool is not defined" |
| 36 |
#endif |
| 37 |
#ifndef false |
| 38 |
"error: false is not defined" |
| 39 |
#endif |
| 40 |
#if false |
| 41 |
"error: false is not 0" |
| 42 |
#endif |
| 43 |
#ifndef true |
| 44 |
"error: true is not defined" |
| 45 |
#endif |
| 46 |
#if true != 1 |
| 47 |
"error: true is not 1" |
| 48 |
#endif |
| 49 |
#ifndef __bool_true_false_are_defined |
| 50 |
"error: __bool_true_false_are_defined is not defined" |
| 51 |
#endif |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
#if HAVE_STDBOOL_H || 3 <= __GNUC__ |
| 56 |
struct s { _Bool s: 1; _Bool t; } s; |
| 57 |
#endif |
| 58 |
|
| 59 |
char a[true == 1 ? 1 : -1]; |
| 60 |
char b[false == 0 ? 1 : -1]; |
| 61 |
char c[__bool_true_false_are_defined == 1 ? 1 : -1]; |
| 62 |
#if HAVE_STDBOOL_H || 3 <= __GNUC__ |
| 63 |
char d[(bool) 0.5 == true ? 1 : -1]; |
| 64 |
# ifdef ADDRESS_CHECK_OKAY |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
# ifdef __GNUC__ |
| 69 |
bool e = &s; |
| 70 |
# endif |
| 71 |
# endif |
| 72 |
char f[(_Bool) 0.0 == false ? 1 : -1]; |
| 73 |
#endif |
| 74 |
char g[true]; |
| 75 |
char h[sizeof (_Bool)]; |
| 76 |
#if HAVE_STDBOOL_H || 3 <= __GNUC__ |
| 77 |
char i[sizeof s.t]; |
| 78 |
#endif |
| 79 |
enum { j = false, k = true, l = false * true, m = true * 256 }; |
| 80 |
_Bool n[m]; |
| 81 |
char o[sizeof n == m * sizeof n[0] ? 1 : -1]; |
| 82 |
char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
_Bool q = true; |
| 88 |
_Bool *pq = &q; |
| 89 |
|
| 90 |
int |
| 91 |
main () |
| 92 |
{ |
| 93 |
int error = 0; |
| 94 |
|
| 95 |
#if HAVE_STDBOOL_H || 3 <= __GNUC__ |
| 96 |
# ifdef ADDRESS_CHECK_OKAY |
| 97 |
|
| 98 |
{ |
| 99 |
bool e1 = &s; |
| 100 |
if (!e1) |
| 101 |
error = 1; |
| 102 |
} |
| 103 |
# endif |
| 104 |
#endif |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
{ |
| 112 |
char digs[] = "0123456789"; |
| 113 |
if (&(digs + 5)[-2 + (bool) 1] != &digs[4]) |
| 114 |
error = 1; |
| 115 |
} |
| 116 |
|
| 117 |
return error; |
| 118 |
} |