struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-960416-1.c
blob0ee3ecb281a5749712d23056eb7b607cd88d8940
1 /*
2 960416-1.c from the execute part of the gcc torture suite.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #endif
11 // TODO: Enable when sdcc can pass struct!
12 #if 0
13 typedef unsigned long int st;
14 typedef unsigned long long dt;
15 typedef union
17 dt d;
18 struct
20 st h, l;
23 } t_be;
25 typedef union
27 dt d;
28 struct
30 st l, h;
33 } t_le;
35 #define df(f, t) \
36 int \
37 f (t afh, t bfh) \
38 { \
39 t hh; \
40 t hp, lp, dp, m; \
41 st ad, bd; \
42 int s; \
43 s = 0; \
44 ad = afh.s.h - afh.s.l; \
45 bd = bfh.s.l - bfh.s.h; \
46 if (bd > bfh.s.l) \
47 { \
48 bd = -bd; \
49 s = ~s; \
50 } \
51 lp.d = (dt) afh.s.l * bfh.s.l; \
52 hp.d = (dt) afh.s.h * bfh.s.h; \
53 dp.d = (dt) ad *bd; \
54 dp.d ^= s; \
55 hh.d = hp.d + hp.s.h + lp.s.h + dp.s.h; \
56 m.d = (dt) lp.s.h + hp.s.l + lp.s.l + dp.s.l; \
57 return hh.s.l + m.s.l; \
60 df(f_le, t_le)
61 df(f_be, t_be)
62 #endif
64 void
65 testTortureExecute (void)
67 #if 0
68 t_be x;
69 x.s.h = 0x10000000U;
70 x.s.l = 0xe0000000U;
71 if (x.d == 0x10000000e0000000ULL
72 && f_be ((t_be) 0x100000000ULL, (t_be) 0x100000000ULL) != -1)
73 ASSERT (0);
74 if (x.d == 0xe000000010000000ULL
75 && f_le ((t_le) 0x100000000ULL, (t_le) 0x100000000ULL) != -1)
76 ASSERT (0);
77 return;
78 #endif