struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-pr60454.c
blobc55f563ef8876fb1e505bdfee1b0453f934a34cc
1 /*
2 pr60454.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 <stdint.h>
12 #include <limits.h>
14 #define fake_const_swab32(x) ((uint32_t)( \
15 (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
16 (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \
17 (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 8) | \
18 (((uint32_t)(x) & (uint32_t)0x0000ff00UL) ) | \
19 (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))
21 /* Previous version of bswap optimization would detect byte swap when none
22 happen. This test aims at catching such wrong detection to avoid
23 regressions. */
25 #ifndef __SDCC_pdk14 // Lack of memory
26 uint32_t
27 fake_swap32 (uint32_t in)
29 return fake_const_swab32 (in);
31 #endif
33 void
34 testTortureExecute (void)
36 #ifndef __SDCC_pdk14 // Lack of memory
37 if (sizeof (uint32_t) * CHAR_BIT != 32)
38 return;
39 if (fake_swap32 (0x12345678UL) != 0x78567E12UL)
40 ASSERT (0);
41 #endif