struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20071219-1.c
bloba38b41a968d41511bd43bbf73397a968916980ec
1 /*
2 20071219-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 /* PR c++/34459 */
15 struct S
17 char s[25];
20 struct S *p;
22 void
23 foo (struct S *x, int set)
25 int i;
26 for (i = 0; i < sizeof (x->s); ++i)
27 if (x->s[i] != 0)
28 ASSERT (0);
29 else if (set)
30 x->s[i] = set;
31 p = x;
34 #if 0 // TODO: Enable when non-braced struct initialization is supported!
35 void
36 ftest1 (void)
38 struct S a;
39 memset (&a.s, '\0', sizeof (a.s));
40 foo (&a, 0);
41 struct S b = a;
42 foo (&b, 1);
43 b = a;
44 b = b;
45 foo (&b, 0);
48 void
49 ftest2 (void)
51 struct S a;
52 memset (&a.s, '\0', sizeof (a.s));
53 foo (&a, 0);
54 struct S b = a;
55 foo (&b, 1);
56 b = a;
57 b = *p;
58 foo (&b, 0);
61 void
62 ftest3 (void)
64 struct S a;
65 memset (&a.s, '\0', sizeof (a.s));
66 foo (&a, 0);
67 struct S b = a;
68 foo (&b, 1);
69 *p = a;
70 *p = b;
71 foo (&b, 0);
73 #endif
75 void
76 testTortureExecute (void)
78 #if 0
79 ftest1 ();
80 ftest2 ();
81 ftest3 ();
82 return 0;
83 #endif