struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20010910-1.c
blob8892f646e2453455e3aaf9f1f47a3f3df72f88e0
1 /*
2 20010910-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 /* Test case contributed by Ingo Rohloff <rohloff@in.tum.de>.
12 Code distilled from Linux kernel. */
14 /* Compile this program with a gcc-2.95.2 using
15 "gcc -O2" and run it. The result will be that
16 rx_ring[1].next == 0 (it should be == 14)
17 and
18 ep.skbuff[4] == 5 (it should be 0)
21 #ifndef __SDCC_pdk14 // Lack of memory
22 extern void abort(void);
24 struct epic_rx_desc
26 unsigned int next;
29 struct epic_private
31 struct epic_rx_desc *rx_ring;
32 unsigned int rx_skbuff[5];
35 static void epic_init_ring(struct epic_private *ep)
37 int i;
39 for (i = 0; i < 5; i++)
41 ep->rx_ring[i].next = 10 + (i+1)*2;
42 ep->rx_skbuff[i] = 0;
44 ep->rx_ring[i-1].next = 10;
47 static int check_rx_ring[5] = { 12,14,16,18,10 };
48 #endif
50 void
51 testTortureExecute (void)
53 #ifndef __SDCC_pdk14 // Lack of memory
54 struct epic_private ep;
55 struct epic_rx_desc rx_ring[5];
56 int i;
58 for (i=0;i<5;i++)
60 rx_ring[i].next=0;
61 ep.rx_skbuff[i]=5;
64 ep.rx_ring=rx_ring;
65 epic_init_ring(&ep);
67 for (i=0;i<5;i++)
69 if ( rx_ring[i].next != check_rx_ring[i] ) ASSERT(0);
70 if ( ep.rx_skbuff[i] != 0 ) ASSERT(0);
72 return;
73 #endif