struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bitintconst.c.in
blobbf69d91f0921940a33dcaad4611ecd99f83b4f4c
1 /** integer constants of bit-precise integer types
3 width: 2, 4, 6, 7, 8, 9, 15, 16, 17, 24, 32, 33, 40, 48, 63, 64, 65
4 */
6 #include <testfwk.h>
8 #pragma disable_warning 264
9 #pragma disable_warning 273
11 #include <limits.h>
13 // clang 11 supports bit-precise types, but deviates a bit from C23.
14 #if __clang_major__ == 11
15 #define __SDCC_BITINT_MAXWIDTH 128
16 #define _BitInt _ExtInt
17 #endif
19 #if __SDCC_BITINT_MAXWIDTH >= {width} // TODO: When we can regression-test in --std-c23 mode, use the standard macro from limits.h instead!
21 typedef unsigned _BitInt({width}) bitinttype;
23 volatile bitinttype i = 0x01wb;
24 volatile bitinttype j = 0x0'1'0wb;
25 volatile bitinttype k = 0b1wb;
26 volatile bitinttype l = 0x01wbu;
27 volatile bitinttype m = 0x0'1'0wbu;
28 volatile bitinttype n = 0b1uwb;
30 #endif
32 void testBitInt(void)
34 #if __SDCC_BITINT_MAXWIDTH >= {width}
35 ASSERT(i == 0x01wb);
36 ASSERT(j == (bitinttype)0x0'1'0wb);
37 ASSERT(k == 0b1wb);
38 ASSERT(l == 0x01uwb);
39 ASSERT(m == (bitinttype)0x0'1'0wbu);
40 ASSERT(n == 0b1wbu);
41 #endif