struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-pr15296.c
blob73a8da6f409e77b9c777b863e670a4218b3e1912
1 /*
2 pr15296.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
6 #include <stdint.h>
8 #ifdef __SDCC
9 #pragma std_c99
10 #pragma disable_warning 85
11 #endif
13 #ifndef __SDCC_pdk14 // Lack of memory - see RFE #607 for details.
15 /* PR optimization/15296. The delayed-branch scheduler caused code that
16 SEGV:d for CRIS; a register was set to -1 in a delay-slot for the
17 fall-through code, while that register held a pointer used in code at
18 the branch target. */
20 /* Assume that if stdint.h defined INTPTR_MAX, it has also defined intptr_t */
21 /* oƒ otherwise, define it ourselves */
22 #ifndef INTPTR_MAX
23 typedef int intptr_t;
24 #endif
26 typedef intptr_t W;
27 union u0
29 union u0 *r;
30 W i;
32 struct s1
34 union u0 **m0;
35 union u0 m1[4];
38 #if !(defined(__SDCC_pic14) && !defined(__SDCC_PIC14_ENHANCED)) // Pseudo-stack size limit
39 void f (void *, struct s1 *, const union u0 *, W, W, W);
40 void g (void *, char *);
42 void
43 f (void *a, struct s1 *b, const union u0 *h, W v0, W v1, W v4)
45 union u0 *e = 0;
46 union u0 *k = 0;
47 union u0 **v5 = b->m0;
48 union u0 *c = b->m1;
49 union u0 **d = &v5[0];
50 l0:;
51 if (v0 < v1)
52 goto l0;
53 if (v0 == 0)
54 goto l3;
55 v0 = v4;
56 if (v0 != 0)
57 goto l3;
58 c[0].r = *d;
59 v1 = -1;
60 e = c[0].r;
61 if (e != 0)
62 g (a, "");
63 k = e + 3;
64 k->i = v1;
65 goto l4;
66 l3:;
67 c[0].i = v0;
68 e = c[1].r;
69 if (e != 0)
70 g (a, "");
71 e = c[0].r;
72 if (e == 0)
73 g (a, "");
74 k = e + 2;
75 k->r = c[1].r;
76 l4:;
79 void g (void *a, char *b) { ASSERT(0); }
80 #endif
81 #endif
83 void
84 testTortureExecute (void)
86 #ifndef __SDCC_pdk14 // Lack of memory - see RFE #607 for details.
87 #ifndef __SDCC_pic16
88 union u0 uv[] = {{ .i = 111 }, { .i = 222 }, { .i = 333 }, { .i = 444 }};
89 struct s1 s = { 0, {{ .i = 555 }, { .i = 0 }, { .i = 999 }, { .i = 777 }}};
90 #if !(defined(__SDCC_pic14) && !defined(__SDCC_PIC14_ENHANCED)) // Pseudo-stack size limit
91 f (0, &s, 0, 20000, 10000, (W) uv);
92 if (s.m1[0].i != (W) uv || s.m1[1].i != 0 || s.m1[2].i != 999
93 || s.m1[3].i != 777 || uv[0].i != 111 || uv[1].i != 222
94 || uv[2].i != 0 || uv[3].i != 444)
95 ASSERT (0);
96 return;
97 #endif
98 #endif
99 #endif