struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20030717-1.c
blobaf316a1c5e22fa236db7423ca29a6ab24393b5f2
1 /*
2 20030717-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 /* PR target/11087
14 This testcase was miscompiled on ppc64, because basic_induction_var called
15 convert_modes, yet did not expect it to emit any new instructions.
16 Those were emitted at the end of the function and destroyed during life
17 analysis, while the program used uninitialized pseudos created by
18 convert_modes. */
20 #ifndef __SDCC_pdk14 // lack of memory
21 struct A
23 unsigned short a1;
24 unsigned long a2;
27 struct B
29 int b1, b2, b3, b4, b5;
32 struct C
34 struct B c1[1];
35 int c2, c3;
38 static
39 int foo (int x)
41 return x < 0 ? -x : x;
44 int bar (struct C *x, struct A *y)
46 int a = x->c3;
47 const int b = y->a1 >> 9;
48 const unsigned long c = y->a2;
49 int d = a;
50 unsigned long e, f;
52 f = foo (c - x->c1[d].b4);
55 if (d <= 0)
56 d = x->c2;
57 d--;
59 e = foo (c-x->c1[d].b4);
60 if (e < f)
61 a = d;
63 while (d != x->c3);
64 x->c1[a].b4 = c + b;
65 return a;
67 #endif
69 void
70 testTortureExecute (void)
72 #ifndef __SDCC_pdk14 // lack of memory
73 struct A a;
74 struct C b;
75 int c;
77 a.a1 = 512;
78 a.a2 = 4242;
79 memset (&b, 0, sizeof (b));
80 b.c1[0].b3 = 424242;
81 b.c2 = 1;
82 c = bar (&b, &a);
83 return;
84 #endif