1 /* Test TS 18661-1 width macros in <stdint.h>. */
2 /* { dg-do compile } */
3 /* { dg-options "-std=c11 -ffreestanding" } */
4 /* { dg-additional-options "-DSIGNAL_SUPPRESS" { target { ! signal } } } */
7 #define __STDC_WANT_IEC_60559_BFP_EXT__
9 #ifndef SIGNAL_SUPPRESS
12 typedef __WINT_TYPE__
wint_t;
14 #define CHECK_WIDTH(TYPE, MAX, WIDTH) \
15 _Static_assert ((MAX >> ((TYPE) -1 < 0 ? (WIDTH - 2) : (WIDTH - 1))) == 1, \
16 "width must match type")
20 # error "missing INT8_WIDTH"
22 CHECK_WIDTH (int8_t, INT8_MAX
, INT8_WIDTH
);
26 # error "missing INT16_WIDTH"
28 CHECK_WIDTH (int16_t, INT16_MAX
, INT16_WIDTH
);
32 # error "missing INT32_WIDTH"
34 CHECK_WIDTH (int32_t, INT32_MAX
, INT32_WIDTH
);
38 # error "missing INT64_WIDTH"
40 CHECK_WIDTH (int64_t, INT64_MAX
, INT64_WIDTH
);
44 # error "missing UINT8_WIDTH"
46 CHECK_WIDTH (uint8_t, UINT8_MAX
, UINT8_WIDTH
);
50 # error "missing UINT16_WIDTH"
52 CHECK_WIDTH (uint16_t, UINT16_MAX
, UINT16_WIDTH
);
56 # error "missing UINT32_WIDTH"
58 CHECK_WIDTH (uint32_t, UINT32_MAX
, UINT32_WIDTH
);
62 # error "missing UINT64_WIDTH"
64 CHECK_WIDTH (uint64_t, UINT64_MAX
, UINT64_WIDTH
);
67 #ifndef INT_LEAST8_WIDTH
68 # error "missing INT_LEAST8_WIDTH"
70 CHECK_WIDTH (int_least8_t, INT_LEAST8_MAX
, INT_LEAST8_WIDTH
);
71 #ifndef INT_LEAST16_WIDTH
72 # error "missing INT_LEAST16_WIDTH"
74 CHECK_WIDTH (int_least16_t, INT_LEAST16_MAX
, INT_LEAST16_WIDTH
);
75 #ifndef INT_LEAST32_WIDTH
76 # error "missing INT_LEAST32_WIDTH"
78 CHECK_WIDTH (int_least32_t, INT_LEAST32_MAX
, INT_LEAST32_WIDTH
);
79 #ifndef INT_LEAST64_WIDTH
80 # error "missing INT_LEAST64_WIDTH"
82 CHECK_WIDTH (int_least64_t, INT_LEAST64_MAX
, INT_LEAST64_WIDTH
);
83 #ifndef INT_LEAST8_WIDTH
84 # error "missing INT_LEAST8_WIDTH"
86 CHECK_WIDTH (uint_least8_t, UINT_LEAST8_MAX
, UINT_LEAST8_WIDTH
);
87 #ifndef UINT_LEAST16_WIDTH
88 # error "missing UINT_LEAST16_WIDTH"
90 CHECK_WIDTH (uint_least16_t, UINT_LEAST16_MAX
, UINT_LEAST16_WIDTH
);
91 #ifndef UINT_LEAST32_WIDTH
92 # error "missing UINT_LEAST32_WIDTH"
94 CHECK_WIDTH (uint_least32_t, UINT_LEAST32_MAX
, UINT_LEAST32_WIDTH
);
95 #ifndef UINT_LEAST64_WIDTH
96 # error "missing UINT_LEAST64_WIDTH"
98 CHECK_WIDTH (uint_least64_t, UINT_LEAST64_MAX
, UINT_LEAST64_WIDTH
);
100 #ifndef INT_FAST8_WIDTH
101 # error "missing INT_FAST8_WIDTH"
103 CHECK_WIDTH (int_fast8_t, INT_FAST8_MAX
, INT_FAST8_WIDTH
);
104 #ifndef INT_FAST16_WIDTH
105 # error "missing INT_FAST16_WIDTH"
107 CHECK_WIDTH (int_fast16_t, INT_FAST16_MAX
, INT_FAST16_WIDTH
);
108 #ifndef INT_FAST32_WIDTH
109 # error "missing INT_FAST32_WIDTH"
111 CHECK_WIDTH (int_fast32_t, INT_FAST32_MAX
, INT_FAST32_WIDTH
);
112 #ifndef INT_FAST64_WIDTH
113 # error "missing INT_FAST64_WIDTH"
115 CHECK_WIDTH (int_fast64_t, INT_FAST64_MAX
, INT_FAST64_WIDTH
);
116 #ifndef INT_FAST8_WIDTH
117 # error "missing INT_FAST8_WIDTH"
119 CHECK_WIDTH (uint_fast8_t, UINT_FAST8_MAX
, UINT_FAST8_WIDTH
);
120 #ifndef UINT_FAST16_WIDTH
121 # error "missing UINT_FAST16_WIDTH"
123 CHECK_WIDTH (uint_fast16_t, UINT_FAST16_MAX
, UINT_FAST16_WIDTH
);
124 #ifndef UINT_FAST32_WIDTH
125 # error "missing UINT_FAST32_WIDTH"
127 CHECK_WIDTH (uint_fast32_t, UINT_FAST32_MAX
, UINT_FAST32_WIDTH
);
128 #ifndef UINT_FAST64_WIDTH
129 # error "missing UINT_FAST64_WIDTH"
131 CHECK_WIDTH (uint_fast64_t, UINT_FAST64_MAX
, UINT_FAST64_WIDTH
);
134 # ifndef INTPTR_WIDTH
135 # error "missing INTPTR_WIDTH"
137 CHECK_WIDTH (intptr_t, INTPTR_MAX
, INTPTR_WIDTH
);
140 # ifndef UINTPTR_WIDTH
141 # error "missing UINTPTR_WIDTH"
143 CHECK_WIDTH (uintptr_t, UINTPTR_MAX
, UINTPTR_WIDTH
);
147 # error "missing INTMAX_WIDTH"
149 CHECK_WIDTH (intmax_t, INTMAX_MAX
, INTMAX_WIDTH
);
150 #ifndef UINTMAX_WIDTH
151 # error "missing UINTMAX_WIDTH"
153 CHECK_WIDTH (uintmax_t, UINTMAX_MAX
, UINTMAX_WIDTH
);
155 #ifndef PTRDIFF_WIDTH
156 # error "missing PTRDIFF_WIDTH"
158 CHECK_WIDTH (ptrdiff_t, PTRDIFF_MAX
, PTRDIFF_WIDTH
);
159 #ifndef SIGNAL_SUPPRESS
160 # ifndef SIG_ATOMIC_WIDTH
161 # error "missing SIG_ATOMIC_WIDTH"
163 CHECK_WIDTH (sig_atomic_t, SIG_ATOMIC_MAX
, SIG_ATOMIC_WIDTH
);
166 # error "missing SIZE_WIDTH"
168 CHECK_WIDTH (size_t, SIZE_MAX
, SIZE_WIDTH
);
170 # error "missing WCHAR_WIDTH"
172 CHECK_WIDTH (wchar_t, WCHAR_MAX
, WCHAR_WIDTH
);
174 # error "missing WINT_WIDTH"
176 CHECK_WIDTH (wint_t, WINT_MAX
, WINT_WIDTH
);