struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-bitfld-3.c
blob829b6f3e76eee2568a5567476e565fd23f97b42e
1 /*
2 bitfld-3.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 /* Test that operations on bit-fields yield results reduced to bit-field
8 type. */
9 /* Origin: Joseph Myers <jsm@polyomino.org.uk> */
10 #if 0 // Enable when SDCC supports bit-fields wider than 16 bits
12 struct s {
13 unsigned long long u33: 33;
14 unsigned long long u40: 40;
15 unsigned long long u41: 41;
18 struct s a = { 0x100000, 0x100000, 0x100000 };
19 struct s b = { 0x100000000ULL, 0x100000000ULL, 0x100000000ULL };
20 struct s c = { 0x1FFFFFFFFULL, 0, 0 };
21 #endif
23 void
24 testTortureExecute (void)
26 #if 0 // Enable when SDCC supports bit-fields wider than 16 bits
27 if (a.u33 * a.u33 != 0 || a.u33 * a.u40 != 0 || a.u40 * a.u33 != 0
28 || a.u40 * a.u40 != 0)
29 abort ();
30 if (a.u33 * a.u41 != 0x10000000000ULL
31 || a.u40 * a.u41 != 0x10000000000ULL
32 || a.u41 * a.u33 != 0x10000000000ULL
33 || a.u41 * a.u40 != 0x10000000000ULL
34 || a.u41 * a.u41 != 0x10000000000ULL)
35 abort ();
36 if (b.u33 + b.u33 != 0)
37 abort ();
38 if (b.u33 + b.u40 != 0x200000000ULL
39 || b.u33 + b.u41 != 0x200000000ULL
40 || b.u40 + b.u33 != 0x200000000ULL
41 || b.u40 + b.u40 != 0x200000000ULL
42 || b.u40 + b.u41 != 0x200000000ULL
43 || b.u41 + b.u33 != 0x200000000ULL
44 || b.u41 + b.u40 != 0x200000000ULL
45 || b.u41 + b.u41 != 0x200000000ULL)
46 abort ();
47 if (a.u33 - b.u33 != 0x100100000ULL
48 || a.u33 - b.u40 != 0xFF00100000ULL
49 || a.u33 - b.u41 != 0x1FF00100000ULL
50 || a.u40 - b.u33 != 0xFF00100000ULL
51 || a.u40 - b.u40 != 0xFF00100000ULL
52 || a.u40 - b.u41 != 0x1FF00100000ULL
53 || a.u41 - b.u33 != 0x1FF00100000ULL
54 || a.u41 - b.u40 != 0x1FF00100000ULL
55 || a.u41 - b.u41 != 0x1FF00100000ULL)
56 abort ();
57 if (++c.u33 != 0 || --c.u40 != 0xFFFFFFFFFFULL || c.u41-- != 0)
58 abort ();
59 exit (0);
60 #endif