struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20020529-1.c
blobffa534bc94e8a99f889b5e9fb806ffc9223a206f
1 /*
2 20020529-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 #pragma disable_warning 85
13 /* PR target/6838 from cato@df.lth.se.
14 cris-elf got an ICE with -O2: the insn matching
15 (insn 49 48 52 (parallel[
16 (set (mem/s:HI (plus:SI (reg/v/f:SI 0 r0 [24])
17 (const_int 8 [0x8])) [5 <variable>.c+0 S2 A8])
18 (reg:HI 2 r2 [27]))
19 (set (reg/f:SI 2 r2 [31])
20 (plus:SI (reg/v/f:SI 0 r0 [24])
21 (const_int 8 [0x8])))
22 ] ) 24 {*mov_sidehi_mem} (nil)
23 (nil))
24 forced a splitter through the output pattern "#", but there was no
25 matching splitter. */
27 struct xx
29 int a;
30 struct xx *b;
31 short c;
34 int f1 (struct xx *);
35 void f2 (void);
37 int
38 foo (struct xx *p, int b, int c, int d)
40 int a;
42 for (;;)
44 a = f1(p);
45 if (a)
46 return (0);
47 if (b)
48 continue;
49 p->c = d;
50 if (p->a)
51 f2 ();
52 if (c)
53 f2 ();
54 d = p->c;
55 switch (a)
57 case 1:
58 if (p->b)
59 f2 ();
60 if (c)
61 f2 ();
62 default:
63 break;
66 return d;
69 void testTortureExecute (void)
71 struct xx s = {0, &s, 23};
72 if (foo (&s, 0, 0, 0) != 0 || s.a != 0 || s.b != &s || s.c != 0)
73 ASSERT (0);
74 return;
77 int
78 f1 (struct xx *p)
80 static int beenhere = 0;
81 if (beenhere++ > 1)
82 ASSERT (0);
83 return beenhere > 1;
86 void
87 f2 (void)
89 ASSERT (0);