2 This test checks promotion of bitfields. Bitfields should be promoted
3 very much like chars and shorts:
5 Bitfields (signed or unsigned) should be promoted to signed int if their
6 value will fit in a signed int, otherwise to an unsigned int if their
7 value will fit in an unsigned int, otherwise we don't promote them (ANSI/ISO
8 does not specify the behavior of bitfields larger than an unsigned int).
10 We test the behavior by subtracting two from the promoted value: this will
11 result in a negitive value for signed types, a positive value for unsigned
12 types. This test (of course) assumes that the compiler is correctly
13 implementing signed and unsigned arithmetic.
18 signed long int s31:31;
19 signed long int s32:32;
20 unsigned long int u31:31;
21 unsigned long int u32:32;
22 unsigned long long ull3 :3;
23 unsigned long long ull35:35;
31 if ((x.u3 - 2) >= 0) /* promoted value should be signed */
34 if ((x.s31 - 2) >= 0) /* promoted value should be signed */
37 if ((x.s32 - 2) >= 0) /* promoted value should be signed */
40 if ((x.u15 - 2) >= 0) /* promoted value should be signed */
43 /* Conditionalize check on whether integers are 4 bytes or larger, i.e.
44 larger than a 31 bit bitfield. */
45 if (sizeof (int) >= 4)
47 if ((x.u31 - 2) >= 0) /* promoted value should be signed */
52 if ((x.u31 - 2) < 0) /* promoted value should be UNsigned */
56 if ((x.u32 - 2) < 0) /* promoted value should be UNsigned */
59 if ((x.ull3 - 2) >= 0) /* promoted value should be signed */
62 if ((x.ull35 - 2) < 0) /* promoted value should be UNsigned */