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-pr61306-1.c
blob6fa725eaff01a1360930954d7abf6cf1ab8f9711
1 /*
2 pr61306-1.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)0x00ff0000UL) >> 8) | \
18 (( (int32_t)(x) & (int32_t)0xff000000UL) >> 24)))
20 /* Previous version of bswap optimization failed to consider sign extension
21 and as a result would replace an expression *not* doing a bswap by a
22 bswap. */
24 #ifndef __SDCC_pdk14 // Lack of memory
25 uint32_t
26 fake_bswap32 (uint32_t in)
28 return fake_const_swab32 (in);
30 #endif
32 void
33 testTortureExecute (void)
35 #ifndef __SDCC_pdk14 // Lack of memory
36 if (sizeof (int32_t) * CHAR_BIT != 32)
37 return;
38 if (sizeof (uint32_t) * CHAR_BIT != 32)
39 return;
40 if (fake_bswap32 (0x87654321) != 0xffffff87)
41 ASSERT (0);
42 #endif