struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-pr15262.c
blob93cf32578d0497c236c3cf9be3810fb5b854508e
1 /*
2 pr15262.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 /* We used to mis-compile this testcase as we did not know that
12 &a+offsetof(b,a) was the same as &a.b */
13 struct A
15 int t;
16 int i;
19 void
20 bar (float *p)
22 *p = 5.2;
25 #ifndef __SDCC_pdk14 // Lack of memory
26 int
27 foo(struct A *locp, int i, int str)
29 float f, g, *p;
30 int T355;
31 int *T356;
32 /* Currently, the alias analyzer has limited support for handling
33 aliases of structure fields when no other variables are aliased.
34 Introduce additional aliases to confuse it. */
35 p = i ? &g : &f;
36 bar (p);
37 if (*p > 0.0)
38 str = 1;
40 T355 = locp->i;
41 T356 = &locp->i;
42 *T356 = str;
43 T355 = locp->i;
45 return T355;
47 #endif
49 void
50 testTortureExecute (void)
52 #ifndef __SDCC_pdk14 // Lack of memory
53 struct A loc;
54 int str;
56 loc.i = 2;
57 str = foo (&loc, 10, 3);
58 if (str!=1)
59 ASSERT (0);
60 return;
61 #endif