Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-pr63843.c
blobbea5cf0369c4aa01065ec7a51172ac5e87347eea
1 /*
2 pr60822.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 <limits.h>
12 #include <string.h>
14 /* PR rtl-optimization/63843 */
16 static inline
17 unsigned short foo (unsigned short v)
19 return (v << 8) | (v >> 8);
22 unsigned short
23 bar (unsigned char *x)
25 unsigned int a;
26 unsigned short b;
27 memcpy (&a, &x[0], sizeof (a));
28 a ^= 0x80808080U;
29 memcpy (&x[0], &a, sizeof (a));
30 memcpy (&b, &x[2], sizeof (b));
31 return foo (b);
34 void
35 testTortureExecute (void)
37 unsigned char x[8] = { 0x01, 0x01, 0x01, 0x01 };
38 if (CHAR_BIT == 8
39 && sizeof (short) == 2
40 && sizeof (int) == 4
41 && bar (x) != 0x8181U)
42 ASSERT (0);
43 return;