Daniel Dunbar | 3b0db90 | 2008-10-16 02:34:03 +0000 | [diff] [blame] | 1 | // RUN: clang -triple i686-apple-darwin9 %s -fsyntax-only -verify |
| 2 | |
| 3 | #include <stddef.h> |
| 4 | |
| 5 | #pragma pack(4) |
| 6 | |
| 7 | // Baseline |
| 8 | struct s0 { |
| 9 | char f0; |
| 10 | int f1; |
| 11 | }; |
| 12 | extern int a0[offsetof(struct s0, f1) == 4 ? 1 : -1]; |
| 13 | |
| 14 | #pragma pack(push, 2) |
| 15 | struct s1 { |
| 16 | char f0; |
| 17 | int f1; |
| 18 | }; |
| 19 | extern int a1[offsetof(struct s1, f1) == 2 ? 1 : -1]; |
| 20 | #pragma pack(pop) |
| 21 | |
| 22 | // Test scope of definition |
| 23 | |
| 24 | #pragma pack(push, 2) |
| 25 | struct s2_0 { |
| 26 | #pragma pack(pop) |
| 27 | char f0; |
| 28 | int f1; |
| 29 | }; |
| 30 | extern int a2_0[offsetof(struct s2_0, f1) == 2 ? 1 : -1]; |
| 31 | |
| 32 | struct s2_1 { |
| 33 | char f0; |
| 34 | #pragma pack(push, 2) |
| 35 | int f1; |
| 36 | #pragma pack(pop) |
| 37 | }; |
| 38 | extern int a2_1[offsetof(struct s2_1, f1) == 4 ? 1 : -1]; |
| 39 | |
| 40 | struct s2_2 { |
| 41 | char f0; |
| 42 | int f1; |
| 43 | #pragma pack(push, 2) |
| 44 | }; |
| 45 | #pragma pack(pop) |
| 46 | extern int a2_2[offsetof(struct s2_2, f1) == 4 ? 1 : -1]; |
| 47 | |
| 48 | struct s2_3 { |
| 49 | char f0; |
| 50 | #pragma pack(push, 2) |
| 51 | struct s2_3_0 { |
| 52 | #pragma pack(pop) |
| 53 | int f0; |
| 54 | } f1; |
| 55 | }; |
| 56 | extern int a2_3[offsetof(struct s2_3, f1) == 2 ? 1 : -1]; |
| 57 | |
| 58 | struct s2_4 { |
| 59 | char f0; |
| 60 | struct s2_4_0 { |
| 61 | int f0; |
| 62 | #pragma pack(push, 2) |
| 63 | } f1; |
| 64 | #pragma pack(pop) |
| 65 | }; |
| 66 | extern int a2_4[offsetof(struct s2_4, f1) == 4 ? 1 : -1]; |