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.
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 if (sizeof (struct { unsigned long u32:32;}) <= sizeof (int))
45 if ((x.u31 - 2) >= 0) /* promoted value should be signed */
50 if ((x.u31 - 2) < 0) /* promoted value should be UNsigned */
54 if ((x.u32 - 2) < 0) /* promoted value should be UNsigned */
57 if ((x.ull3 - 2) >= 0) /* promoted value should be signed */
60 if ((x.ull35 - 2) < 0) /* promoted value should be UNsigned */