| 1 |
/* PR target/52991 */ |
| 2 |
/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ |
| 3 |
|
| 4 |
#define CHECK(expr) extern char c[(expr) ? 1 : -1] |
| 5 |
#define offsetof(x, y) __builtin_offsetof (x, y) |
| 6 |
|
| 7 |
struct test_sp1 { |
| 8 |
int a; |
| 9 |
short b; |
| 10 |
int c; |
| 11 |
char d; |
| 12 |
} __attribute__((packed,ms_struct)); |
| 13 |
|
| 14 |
CHECK (sizeof (struct test_sp1) == 11); |
| 15 |
CHECK (offsetof (struct test_sp1, a) == 0); |
| 16 |
CHECK (offsetof (struct test_sp1, b) == 4); |
| 17 |
CHECK (offsetof (struct test_sp1, c) == 6); |
| 18 |
CHECK (offsetof (struct test_sp1, d) == 10); |
| 19 |
|
| 20 |
struct test_sp3 { |
| 21 |
int a; |
| 22 |
short b __attribute__((aligned(8))); |
| 23 |
int c; |
| 24 |
char d; |
| 25 |
} __attribute__((packed,ms_struct)); |
| 26 |
|
| 27 |
CHECK (sizeof (struct test_sp3) == 16); |
| 28 |
CHECK (offsetof (struct test_sp3, a) == 0); |
| 29 |
CHECK (offsetof (struct test_sp3, b) == 8); |
| 30 |
CHECK (offsetof (struct test_sp3, c) == 10); |
| 31 |
CHECK (offsetof (struct test_sp3, d) == 14); |
| 32 |
|
| 33 |
struct test_s4 { |
| 34 |
int a; |
| 35 |
short b; |
| 36 |
int c:15; |
| 37 |
char d; |
| 38 |
} __attribute__((ms_struct)); |
| 39 |
|
| 40 |
CHECK (sizeof (struct test_s4) == 16); |
| 41 |
CHECK (offsetof (struct test_s4, a) == 0); |
| 42 |
CHECK (offsetof (struct test_s4, b) == 4); |
| 43 |
CHECK (offsetof (struct test_s4, d) == 12); |