gcc/testsuite/gcc.dg/field-merge-8.c
raw| 1 | /* { dg-do run } */ |
| 2 | /* { dg-options "-O" } */ |
| 3 | |
| 4 | /* Check that conversions are not thrown away. */ |
| 5 | |
| 6 | struct s { |
| 7 | unsigned char a; |
| 8 | unsigned short b; |
| 9 | } __attribute__ ((aligned (4))); |
| 10 | |
| 11 | struct s p = { 42, 0xfe }; |
| 12 | struct s q = { 42, 0xfe | (2 << (__CHAR_BIT__ - 1)) }; |
| 13 | |
| 14 | void f (void) { |
| 15 | if (0 |
| 16 | || p.a != q.a |
| 17 | || (unsigned char)p.b != (unsigned char)q.b |
| 18 | ) |
| 19 | __builtin_abort (); |
| 20 | } |
| 21 | |
| 22 | int main () { |
| 23 | if (sizeof (short) != 2) |
| 24 | return 0; |
| 25 | f (); |
| 26 | return 0; |
| 27 | } |