gcc/testsuite/gcc.c-torture/execute/bitfld-7.c
raw| 1 | /* { dg-require-effective-target int32plus } */ |
| 2 | union U |
| 3 | { |
| 4 | const int a; |
| 5 | unsigned b : 24; |
| 6 | }; |
| 7 | |
| 8 | static union U u = { 0x12345678 }; |
| 9 | |
| 10 | /* Constant folding used to fail to account for endianness when folding a |
| 11 | union. */ |
| 12 | |
| 13 | int |
| 14 | main (void) |
| 15 | { |
| 16 | #ifdef __BYTE_ORDER__ |
| 17 | #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ |
| 18 | return u.b - 0x345678; |
| 19 | #else |
| 20 | return u.b - 0x123456; |
| 21 | #endif |
| 22 | #endif |
| 23 | return 0; |
| 24 | } |