Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20071210-1.c
blob05d6c0827d1c1a5401c0c78e03f869e1002be2b8
1 /*
2 20071210-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 #if 0 // TODO: Enable when struct can be returned and sdc accepts the array init with && below.
12 /* PR rtl-optimization/34302 */
14 struct S
16 int n1, n2, n3, n4;
19 struct S
20 foo (int x, int y, int z)
22 if (x != 10 || y != 9 || z != 8)
23 ASSERT (0);
24 struct S s = { 1, 2, 3, 4 };
25 return s;
28 void **
29 bar (void **u, int *v)
31 void **w = u;
32 int *s = v, x, y, z;
33 void **p, **q;
34 static void *l[] = { &&lab1, &&lab1, &&lab2, &&lab3, &&lab4 };
36 if (!u)
37 return l;
39 q = *w++;
40 goto *q;
41 lab2:
42 p = q;
43 q = *w++;
44 x = s[2];
45 y = s[1];
46 z = s[0];
47 s -= 1;
48 struct S r = foo (x, y, z);
49 s[3] = r.n1;
50 s[2] = r.n2;
51 s[1] = r.n3;
52 s[0] = r.n4;
53 goto *q;
54 lab3:
55 p = q;
56 q = *w++;
57 s += 1;
58 s[0] = 23;
59 lab1:
60 goto *q;
61 lab4:
62 return 0;
64 #endif
66 void
67 testTortureExecute (void)
69 #if 0
70 void **u = bar ((void **) 0, (int *) 0);
71 void *t[] = { u[2], u[4] };
72 int s[] = { 7, 8, 9, 10, 11, 12 };
73 if (bar (t, &s[1]) != (void **) 0
74 || s[0] != 4 || s[1] != 3 || s[2] != 2 || s[3] != 1
75 || s[4] != 11 || s[5] != 12)
76 ASSERT (0);
77 return;
78 #endif