struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20030313-1.c
blob99aec8fcbcf716c155c6500a480b4097527073a5
1 /*
2 20030313-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 #if !defined(__SDCC_mcs51) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
12 struct A
14 unsigned long p, q, r, s;
15 } x = { 13, 14, 15, 16 };
17 extern void abort (void);
18 extern void exit (int);
20 static inline struct A *
21 bar (void)
23 struct A *r;
25 switch (8)
27 case 2:
28 ASSERT (0);
29 break;
30 case 8:
31 r = &x;
32 break;
33 default:
34 ASSERT (0);
35 break;
37 return r;
40 void
41 foo (unsigned long *x, int y)
43 if (y != 12)
44 ASSERT (0);
45 if (x[0] != 1 || x[1] != 11)
46 ASSERT (0);
47 if (x[2] != 2 || x[3] != 12)
48 ASSERT (0);
49 if (x[4] != 3 || x[5] != 13)
50 ASSERT (0);
51 if (x[6] != 4 || x[7] != 14)
52 ASSERT (0);
53 if (x[8] != 5 || x[9] != 15)
54 ASSERT (0);
55 if (x[10] != 6 || x[11] != 16)
56 ASSERT (0);
58 #endif
60 void
61 testTortureExecute (void)
63 #if !defined(__SDCC_mcs51) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
64 unsigned long a[40];
65 int b = 0;
67 a[b++] = 1;
68 a[b++] = 11;
69 a[b++] = 2;
70 a[b++] = 12;
71 a[b++] = 3;
72 a[b++] = bar()->p;
73 a[b++] = 4;
74 a[b++] = bar()->q;
75 a[b++] = 5;
76 a[b++] = bar()->r;
77 a[b++] = 6;
78 a[b++] = bar()->s;
79 foo (a, b);
80 return;
81 #endif