struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20031215-1.c
blob221faac52f7a15ae1b5350ec53bd9169fe56d730
1 /*
2 20031215-1.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #endif
11 /* PR middle-end/13400 */
12 /* The following test used to fail at run-time with a write to read-only
13 memory, caused by if-conversion converting a conditional write into an
14 unconditional write. */
16 typedef struct {int c, l; char ch[3];} pstr;
17 const pstr ao = {2, 2, "OK"};
18 const pstr * const a = &ao;
20 void test1(void)
22 if (a->ch[a->l]) {
23 ((char *)a->ch)[a->l] = 0;
27 void test2(void)
29 if (a->ch[a->l]) {
30 ((char *)a->ch)[a->l] = -1;
34 void test3(void)
36 if (a->ch[a->l]) {
37 ((char *)a->ch)[a->l] = 1;
41 void
42 testTortureExecute (void)
44 test1();
45 test2();
46 test3();
47 return;