1 /** bit-precise integer types allow wider bit-fields than int.
3 width: 7, 17, 24, 32, 33, 40, 48, 63, 64, 65
11 // clang 11 supports bit-precise types, but deviates a bit from C23.
12 #if __clang_major__ == 11
13 #define __SDCC_BITINT_MAXWIDTH 128
14 #define _BitInt _ExtInt
17 #if __SDCC_BITINT_MAXWIDTH >= {width} // TODO: When we can regression-test in --std-c23 mode, use the standard macro from limits.h instead!
18 typedef {sign
} _BitInt({width
}) bitinttype
;
21 bitinttype bw
: {width
};
22 unsigned _BitInt(4) b4
: 4;
27 bitinttype bw
: {width
};
28 unsigned _BitInt(4) b4
: 4;
29 bitinttype bw_1
: {width
} - 1;
33 void testWideBitIntBitField(void)
35 #if __SDCC_BITINT_MAXWIDTH >= {width} // TODO: When we can regression-test in --std-c23 mode, use the standard macro from limits.h instead!
36 #ifndef __clang_major__ // clang 11 doesn't support == between _BitInt and int, and does weird stuff when promoting bit-fields.
37 ASSERT (_Generic(+bf2
.bw
, bitinttype
: 1, default: 0) == 1);
38 ASSERT (_Generic(+bf2
.bw_1
, bitinttype
: 1, default: 0) == 1);
42 ASSERT (bf
.b
== false);
46 ASSERT (bf2
.bw_1
== 5);
50 ASSERT (bf
.bw
== 0x2a);
51 ASSERT (bf2
.bw_1
== 0x15);