struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20000703-1.c
blobc7cc1513859c75ba41b3296c5d57f33c863cbd7c
1 /*
2 20000703-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 #include <string.h>
13 struct baz
15 char a[17];
16 char b[3];
17 unsigned int c;
18 unsigned int d;
21 void foo(struct baz *p, unsigned int c, unsigned int d)
23 memcpy (p->b, "abc", 3);
24 p->c = c;
25 p->d = d;
28 void bar(struct baz *p, unsigned int c, unsigned int d)
30 { void *s = (p);
31 memset (s, '\0', sizeof (struct baz));
32 s; };
33 memcpy (p->a, "01234567890123456", 17);
34 memcpy (p->b, "abc", 3);
35 p->c = c;
36 p->d = d;
39 void
40 testTortureExecute (void)
42 #if !defined(__SDCC_pdk14) // Lack of memory
43 struct baz p;
44 foo(&p, 71, 18);
45 if (p.c != 71 || p.d != 18)
46 ASSERT (0);
47 bar(&p, 59, 26);
48 if (p.c != 59 || p.d != 26)
49 ASSERT (0);
50 return;
51 #endif