struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20100430-1.c
blob0a6e691d66fed2e2a05d0b23863580def894e867
1 /*
2 20100430-1.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 /* This used to generate unaligned accesses at -O2 because of IVOPTS. */
9 #if !(defined(__SDCC_mcs51) && (defined(__SDCC_MODEL_SMALL) || defined(__SDCC_MODEL_MEDIUM) || defined(__SDCC_STACK_AUTO))) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) && !defined(__SDCC_pic14) // Lack of memory
10 struct packed_struct
12 struct packed_struct1
14 unsigned char cc11;
15 unsigned char cc12;
16 } pst1;
17 struct packed_struct2
19 unsigned char cc21;
20 unsigned char cc22;
21 unsigned short ss[104];
22 unsigned char cc23[13];
23 } pst2[4];
26 typedef struct
28 int ii;
29 struct packed_struct buf;
30 } info_t;
32 static unsigned short g;
34 static void
35 dummy (unsigned short s)
37 g = s;
40 static int
41 foo (info_t *info)
43 int i, j;
45 for (i = 0; i < info->buf.pst1.cc11; i++)
46 for (j = 0; j < info->buf.pst2[i].cc22; j++)
47 dummy (info->buf.pst2[i].ss[j]);
49 return 0;
52 int
53 wrapper (void)
55 info_t info;
56 info.buf.pst1.cc11 = 2;
57 info.buf.pst2[0].cc22 = info.buf.pst2[1].cc22 = 8;
58 return foo (&info);
60 #endif
62 void
63 testTortureExecute (void)
65 #if !(defined(__SDCC_mcs51) && (defined(__SDCC_MODEL_SMALL) || defined(__SDCC_MODEL_MEDIUM) || defined(__SDCC_STACK_AUTO))) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) && !defined(__SDCC_pic14) // Lack of memory
66 wrapper();
67 #endif