1 // RUN: %clang_cc1 -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 #pragma pack(1) 23 struct s3_0 { 24 char f0; 25 int f1; 26 }; 27 #pragma pack() 28 struct s3_1 { 29 char f0; 30 int f1; 31 }; 32 extern int a3_0[offsetof(struct s3_0, f1) == 1 ? 1 : -1]; 33 extern int a3_1[offsetof(struct s3_1, f1) == 4 ? 1 : -1]; 34 35 // pack(0) is like pack() 36 #pragma pack(1) 37 struct s4_0 { 38 char f0; 39 int f1; 40 }; 41 #pragma pack(0) 42 struct s4_1 { 43 char f0; 44 int f1; 45 }; 46 extern int a4_0[offsetof(struct s4_0, f1) == 1 ? 1 : -1]; 47 extern int a4_1[offsetof(struct s4_1, f1) == 4 ? 1 : -1]; 48 49 void f() { 50 #pragma pack(push, 2) 51 struct s5_0 { 52 char f0; 53 struct s2_4_0 { 54 int f0; 55 } f1; 56 }; 57 #pragma pack(pop) 58 extern int s5_0[offsetof(struct s5_0, f1) == 2 ? 1 : -1]; 59 } 60