struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20050826-1.c
blob1a2aec85c252736de895f8b8f610312a0fa29584
1 /*
2 20050826-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 #include <string.h>
13 #if defined __SDCC_pdk14
14 #define SIZE 8 // the available memory is limited
15 #elif defined __SDCC_mcs51 && (__SDCC_MODEL_SMALL || defined __SDCC_MODEL_MEDIUM) || defined __SDCC_pdk15 || defined __SDCC_pic14
16 #define SIZE 64 // the available memory is limited
17 #else
18 #define SIZE 2048
19 #endif
21 /* PR rtl-optimization/23561 */
23 struct A
25 char a1[1];
26 char a2[5];
27 char a3[1];
28 char a4[SIZE - 7];
29 } a;
31 void
32 bar (struct A *x)
34 size_t i;
35 ASSERTFALSE (memcmp (x, "\1HELLO\1", sizeof "\1HELLO\1"));
36 for (i = 0; i < sizeof (x->a4); i++)
37 ASSERTFALSE (x->a4[i]);
40 int
41 foo (void)
43 memset (&a, 0, sizeof (a));
44 a.a1[0] = 1;
45 memcpy (a.a2, "HELLO", sizeof "HELLO");
46 a.a3[0] = 1;
47 bar (&a);
48 return 0;
51 void
52 testTortureExecute (void)
54 foo ();