struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-pr27285.c
blobe8c61984757b94119c99b42db356312ac5fc2907
1 /*
2 pr27285.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 #if !defined (__SDCC_pdk14) // Lack of memory
13 /* PR tree-optimization/27285 */
15 extern void abort (void);
17 struct S { unsigned char a, b, c, d[16]; };
19 void
20 foo (struct S *x, struct S *y)
22 int a, b;
23 unsigned char c, *d, *e;
25 b = x->b;
26 d = x->d;
27 e = y->d;
28 a = 0;
29 while (b)
31 if (b >= 8)
33 c = 0xff;
34 b -= 8;
36 else
38 c = 0xff << (8 - b);
39 b = 0;
42 e[a] = d[a] & c;
43 a++;
46 #endif
48 void
49 testTortureExecute (void)
51 #if !defined (__SDCC_pdk14) // Lack of memory
52 struct S x = { 0, 25, 0, { 0xaa, 0xbb, 0xcc, 0xdd }};
53 struct S y = { 0, 0, 0, { 0 }};
54 foo (&x, &y);
55 if (x.d[0] != y.d[0] || x.d[1] != y.d[1]
56 || x.d[2] != y.d[2] || (x.d[3] & 0x80) != y.d[3])
57 ASSERT (0);
58 return;
59 #endif