struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20050826-2.c
blobaee1404968ab5a2b0a6034e9d8de44d4df33222c
1 /*
2 20050826-2.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 rtl-optimization/23560 */
15 struct rtattr
17 unsigned short rta_len;
18 unsigned short rta_type;
21 int inet_check_attr (void *r, struct rtattr **rta)
23 int i;
25 for (i = 1; i <= 14; i++)
27 struct rtattr *attr = rta[i - 1];
28 if (attr)
30 if (attr->rta_len - sizeof (struct rtattr) < 4)
31 return -22;
32 if (i != 9 && i != 8)
33 rta[i - 1] = attr + 1;
36 return 0;
39 void
40 testTortureExecute (void)
42 #if !defined(__SDCC_pdk14) // Lack of memory
43 struct rtattr rt[2];
44 struct rtattr *rta[14];
45 int i;
47 rt[0].rta_len = sizeof (struct rtattr) + 8;
48 rt[0].rta_type = 0;
49 rt[1] = rt[0];
50 for (i = 0; i < 14; i++)
51 rta[i] = &rt[0];
52 if (inet_check_attr (0, rta) != 0)
53 ASSERT (0);
54 for (i = 0; i < 14; i++)
55 if (rta[i] != &rt[i != 7 && i != 8])
56 ASSERT (0);
57 for (i = 0; i < 14; i++)
58 rta[i] = &rt[0];
59 rta[1] = 0;
60 rt[1].rta_len -= 8;
61 rta[5] = &rt[1];
62 if (inet_check_attr (0, rta) != -22)
63 ASSERT (0);
64 for (i = 0; i < 14; i++)
65 if (i == 1 && rta[i] != 0)
66 ASSERT (0);
67 else if (i != 1 && i <= 5 && rta[i] != &rt[1])
68 ASSERT (0);
69 else if (i > 5 && rta[i] != &rt[0])
70 ASSERT (0);
71 return;
72 #endif