struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-pr61306-2.c
blobf59db297301a5db48b84b528f329453ef250ee75
1 /*
2 pr61306-2.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)(int16_t)(x) & (uint32_t)0x00ffff00UL) << 8) | \
17 (((uint32_t) (x) & (uint32_t)0x00ff0000UL) >> 8) | \
18 (((uint32_t) (x) & (uint32_t)0xff000000UL) >> 24)))
21 /* Previous version of bswap optimization failed to consider sign extension
22 and as a result would replace an expression *not* doing a bswap by a
23 bswap. */
25 #ifndef __SDCC_pdk14 // Lack of memory
26 uint32_t
27 fake_bswap32 (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 (sizeof (int16_t) * CHAR_BIT != 16)
40 return;
41 if (fake_bswap32 (0x81828384) != 0xff838281)
42 ASSERT (0);
43 #endif