1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple i686-apple-darwin9 %s -fsyntax-only -verify 2*f4a2713aSLionel Sambuc // expected-no-diagnostics 3*f4a2713aSLionel Sambuc 4*f4a2713aSLionel Sambuc #include <stddef.h> 5*f4a2713aSLionel Sambuc 6*f4a2713aSLionel Sambuc #pragma pack(4) 7*f4a2713aSLionel Sambuc 8*f4a2713aSLionel Sambuc // Baseline 9*f4a2713aSLionel Sambuc struct s0 { 10*f4a2713aSLionel Sambuc char f0; 11*f4a2713aSLionel Sambuc int f1; 12*f4a2713aSLionel Sambuc }; 13*f4a2713aSLionel Sambuc extern int a0[offsetof(struct s0, f1) == 4 ? 1 : -1]; 14*f4a2713aSLionel Sambuc 15*f4a2713aSLionel Sambuc #pragma pack(push, 2) 16*f4a2713aSLionel Sambuc struct s1 { 17*f4a2713aSLionel Sambuc char f0; 18*f4a2713aSLionel Sambuc int f1; 19*f4a2713aSLionel Sambuc }; 20*f4a2713aSLionel Sambuc extern int a1[offsetof(struct s1, f1) == 2 ? 1 : -1]; 21*f4a2713aSLionel Sambuc #pragma pack(pop) 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuc #pragma pack(1) 24*f4a2713aSLionel Sambuc struct s3_0 { 25*f4a2713aSLionel Sambuc char f0; 26*f4a2713aSLionel Sambuc int f1; 27*f4a2713aSLionel Sambuc }; 28*f4a2713aSLionel Sambuc #pragma pack() 29*f4a2713aSLionel Sambuc struct s3_1 { 30*f4a2713aSLionel Sambuc char f0; 31*f4a2713aSLionel Sambuc int f1; 32*f4a2713aSLionel Sambuc }; 33*f4a2713aSLionel Sambuc extern int a3_0[offsetof(struct s3_0, f1) == 1 ? 1 : -1]; 34*f4a2713aSLionel Sambuc extern int a3_1[offsetof(struct s3_1, f1) == 4 ? 1 : -1]; 35*f4a2713aSLionel Sambuc 36*f4a2713aSLionel Sambuc // pack(0) is like pack() 37*f4a2713aSLionel Sambuc #pragma pack(1) 38*f4a2713aSLionel Sambuc struct s4_0 { 39*f4a2713aSLionel Sambuc char f0; 40*f4a2713aSLionel Sambuc int f1; 41*f4a2713aSLionel Sambuc }; 42*f4a2713aSLionel Sambuc #pragma pack(0) 43*f4a2713aSLionel Sambuc struct s4_1 { 44*f4a2713aSLionel Sambuc char f0; 45*f4a2713aSLionel Sambuc int f1; 46*f4a2713aSLionel Sambuc }; 47*f4a2713aSLionel Sambuc extern int a4_0[offsetof(struct s4_0, f1) == 1 ? 1 : -1]; 48*f4a2713aSLionel Sambuc extern int a4_1[offsetof(struct s4_1, f1) == 4 ? 1 : -1]; 49*f4a2713aSLionel Sambuc f()50*f4a2713aSLionel Sambucvoid f() { 51*f4a2713aSLionel Sambuc #pragma pack(push, 2) 52*f4a2713aSLionel Sambuc struct s5_0 { 53*f4a2713aSLionel Sambuc char f0; 54*f4a2713aSLionel Sambuc struct s2_4_0 { 55*f4a2713aSLionel Sambuc int f0; 56*f4a2713aSLionel Sambuc } f1; 57*f4a2713aSLionel Sambuc }; 58*f4a2713aSLionel Sambuc #pragma pack(pop) 59*f4a2713aSLionel Sambuc extern int s5_0[offsetof(struct s5_0, f1) == 2 ? 1 : -1]; 60*f4a2713aSLionel Sambuc } 61