]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/stdint-width-2.c
1 /* Test C2X width macros in <stdint.h>. */
2 /* { dg-do compile } */
3 /* { dg-options "-std=c2x -ffreestanding" } */
4 /* { dg-additional-options "-DSIGNAL_SUPPRESS" { target { ! signal } } } */
8 #ifndef SIGNAL_SUPPRESS
11 typedef __WINT_TYPE__
wint_t;
13 #define CHECK_WIDTH(TYPE, MAX, WIDTH) \
14 _Static_assert ((MAX >> ((TYPE) -1 < 0 ? (WIDTH - 2) : (WIDTH - 1))) == 1, \
15 "width must match type")
19 # error "missing INT8_WIDTH"
21 CHECK_WIDTH (int8_t, INT8_MAX
, INT8_WIDTH
);
25 # error "missing INT16_WIDTH"
27 CHECK_WIDTH (int16_t, INT16_MAX
, INT16_WIDTH
);
31 # error "missing INT32_WIDTH"
33 CHECK_WIDTH (int32_t, INT32_MAX
, INT32_WIDTH
);
37 # error "missing INT64_WIDTH"
39 CHECK_WIDTH (int64_t, INT64_MAX
, INT64_WIDTH
);
43 # error "missing UINT8_WIDTH"
45 CHECK_WIDTH (uint8_t, UINT8_MAX
, UINT8_WIDTH
);
49 # error "missing UINT16_WIDTH"
51 CHECK_WIDTH (uint16_t, UINT16_MAX
, UINT16_WIDTH
);
55 # error "missing UINT32_WIDTH"
57 CHECK_WIDTH (uint32_t, UINT32_MAX
, UINT32_WIDTH
);
61 # error "missing UINT64_WIDTH"
63 CHECK_WIDTH (uint64_t, UINT64_MAX
, UINT64_WIDTH
);
66 #ifndef INT_LEAST8_WIDTH
67 # error "missing INT_LEAST8_WIDTH"
69 CHECK_WIDTH (int_least8_t, INT_LEAST8_MAX
, INT_LEAST8_WIDTH
);
70 #ifndef INT_LEAST16_WIDTH
71 # error "missing INT_LEAST16_WIDTH"
73 CHECK_WIDTH (int_least16_t, INT_LEAST16_MAX
, INT_LEAST16_WIDTH
);
74 #ifndef INT_LEAST32_WIDTH
75 # error "missing INT_LEAST32_WIDTH"
77 CHECK_WIDTH (int_least32_t, INT_LEAST32_MAX
, INT_LEAST32_WIDTH
);
78 #ifndef INT_LEAST64_WIDTH
79 # error "missing INT_LEAST64_WIDTH"
81 CHECK_WIDTH (int_least64_t, INT_LEAST64_MAX
, INT_LEAST64_WIDTH
);
82 #ifndef INT_LEAST8_WIDTH
83 # error "missing INT_LEAST8_WIDTH"
85 CHECK_WIDTH (uint_least8_t, UINT_LEAST8_MAX
, UINT_LEAST8_WIDTH
);
86 #ifndef UINT_LEAST16_WIDTH
87 # error "missing UINT_LEAST16_WIDTH"
89 CHECK_WIDTH (uint_least16_t, UINT_LEAST16_MAX
, UINT_LEAST16_WIDTH
);
90 #ifndef UINT_LEAST32_WIDTH
91 # error "missing UINT_LEAST32_WIDTH"
93 CHECK_WIDTH (uint_least32_t, UINT_LEAST32_MAX
, UINT_LEAST32_WIDTH
);
94 #ifndef UINT_LEAST64_WIDTH
95 # error "missing UINT_LEAST64_WIDTH"
97 CHECK_WIDTH (uint_least64_t, UINT_LEAST64_MAX
, UINT_LEAST64_WIDTH
);
99 #ifndef INT_FAST8_WIDTH
100 # error "missing INT_FAST8_WIDTH"
102 CHECK_WIDTH (int_fast8_t, INT_FAST8_MAX
, INT_FAST8_WIDTH
);
103 #ifndef INT_FAST16_WIDTH
104 # error "missing INT_FAST16_WIDTH"
106 CHECK_WIDTH (int_fast16_t, INT_FAST16_MAX
, INT_FAST16_WIDTH
);
107 #ifndef INT_FAST32_WIDTH
108 # error "missing INT_FAST32_WIDTH"
110 CHECK_WIDTH (int_fast32_t, INT_FAST32_MAX
, INT_FAST32_WIDTH
);
111 #ifndef INT_FAST64_WIDTH
112 # error "missing INT_FAST64_WIDTH"
114 CHECK_WIDTH (int_fast64_t, INT_FAST64_MAX
, INT_FAST64_WIDTH
);
115 #ifndef INT_FAST8_WIDTH
116 # error "missing INT_FAST8_WIDTH"
118 CHECK_WIDTH (uint_fast8_t, UINT_FAST8_MAX
, UINT_FAST8_WIDTH
);
119 #ifndef UINT_FAST16_WIDTH
120 # error "missing UINT_FAST16_WIDTH"
122 CHECK_WIDTH (uint_fast16_t, UINT_FAST16_MAX
, UINT_FAST16_WIDTH
);
123 #ifndef UINT_FAST32_WIDTH
124 # error "missing UINT_FAST32_WIDTH"
126 CHECK_WIDTH (uint_fast32_t, UINT_FAST32_MAX
, UINT_FAST32_WIDTH
);
127 #ifndef UINT_FAST64_WIDTH
128 # error "missing UINT_FAST64_WIDTH"
130 CHECK_WIDTH (uint_fast64_t, UINT_FAST64_MAX
, UINT_FAST64_WIDTH
);
133 # ifndef INTPTR_WIDTH
134 # error "missing INTPTR_WIDTH"
136 CHECK_WIDTH (intptr_t, INTPTR_MAX
, INTPTR_WIDTH
);
139 # ifndef UINTPTR_WIDTH
140 # error "missing UINTPTR_WIDTH"
142 CHECK_WIDTH (uintptr_t, UINTPTR_MAX
, UINTPTR_WIDTH
);
146 # error "missing INTMAX_WIDTH"
148 CHECK_WIDTH (intmax_t, INTMAX_MAX
, INTMAX_WIDTH
);
149 #ifndef UINTMAX_WIDTH
150 # error "missing UINTMAX_WIDTH"
152 CHECK_WIDTH (uintmax_t, UINTMAX_MAX
, UINTMAX_WIDTH
);
154 #ifndef PTRDIFF_WIDTH
155 # error "missing PTRDIFF_WIDTH"
157 CHECK_WIDTH (ptrdiff_t, PTRDIFF_MAX
, PTRDIFF_WIDTH
);
158 #ifndef SIGNAL_SUPPRESS
159 # ifndef SIG_ATOMIC_WIDTH
160 # error "missing SIG_ATOMIC_WIDTH"
162 CHECK_WIDTH (sig_atomic_t, SIG_ATOMIC_MAX
, SIG_ATOMIC_WIDTH
);
165 # error "missing SIZE_WIDTH"
167 CHECK_WIDTH (size_t, SIZE_MAX
, SIZE_WIDTH
);
169 # error "missing WCHAR_WIDTH"
171 CHECK_WIDTH (wchar_t, WCHAR_MAX
, WCHAR_WIDTH
);
173 # error "missing WINT_WIDTH"
175 CHECK_WIDTH (wint_t, WINT_MAX
, WINT_WIDTH
);