struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-pr20601-1.c
blob77ebbdc1026255efe9d04ed079bbba108ff1d05a
1 /*
2 pr15262.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c11
9 #pragma disable_warning 85
10 #endif
12 /* PR tree-optimization/20601 */
13 /*extern void abort (void);
14 extern void exit (int);*/
16 struct T
18 const char *t1;
19 char t2[4096];
20 char **t3;
23 #if defined (__SDCC) && !defined (__SDCC_mcs51) && !defined (__SDCC_pdk14) && !defined (__SDCC_pdk15) // Lack of memory
24 int a[5];
25 int b;
26 const char **c;
27 int d;
28 const char **e;
29 struct T t;
30 char *f[16];
31 const char *g[] = { "a", "-u", "b", "c" };
33 _Noreturn void
34 foo (void)
36 while (1);
39 char *
40 bar (char *x, unsigned int y)
42 return 0;
45 static inline char *
46 baz (char *x, unsigned int y)
48 if (sizeof (t.t2) != (unsigned int) -1 && y > sizeof (t.t2))
49 foo ();
50 return bar (x, y);
53 static inline int
54 setup1 (int x)
56 char *p;
57 int rval;
59 if (!baz (t.t2, sizeof (t.t2)))
60 baz (t.t2, sizeof (t.t2));
62 if (x & 0x200)
64 char **h, **i = e;
66 ++d;
67 e = f;
68 if (t.t1 && *t.t1)
69 e[0] = t.t1;
70 else
71 ASSERT (0);
73 for (h = e + 1; (*h = *i); ++i, ++h)
76 return 1;
79 static inline int
80 setup2 (void)
82 int j = 1;
84 e = c + 1;
85 d = b - 1;
86 while (d > 0 && e[0][0] == '-')
88 if (e[0][1] != '\0' && e[0][2] != '\0')
89 ASSERT (0);
91 switch (e[0][1])
93 case 'u':
94 if (!e[1])
95 ASSERT (0);
97 t.t3 = &e[1];
98 d--;
99 e++;
100 break;
101 case 'P':
102 j |= 0x1000;
103 break;
104 case '-':
105 d--;
106 e++;
107 if (j == 1)
108 j |= 0x600;
109 return j;
111 d--;
112 e++;
115 if (d > 0 && !(j & 1))
116 ASSERT (0);
118 return j;
120 #endif
122 void
123 testTortureExecute (void)
125 #if defined (__SDCC) && !defined (__SDCC_mcs51) && !defined(__SDCC_pdk14) && !defined (__SDCC_pdk15) // Lack of memory
126 int x;
127 c = g;
128 b = 4;
129 x = setup2 ();
130 t.t1 = "/bin/sh";
131 setup1 (x);
132 /* PRE shouldn't transform x into the constant 0x601 here, it's not legal. */
133 if ((x & 0x400) && !a[4])
134 ASSERT (0);
135 return;
136 #endif