1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -fsyntax-only -verify -ffreestanding 2*f4a2713aSLionel Sambuc // expected-no-diagnostics 3*f4a2713aSLionel Sambuc // <rdar://problem/10494810> and PR9560 4*f4a2713aSLionel Sambuc // Check #pragma pack handling with bitfields. 5*f4a2713aSLionel Sambuc 6*f4a2713aSLionel Sambuc #include <stddef.h> 7*f4a2713aSLionel Sambuc #pragma pack(2) 8*f4a2713aSLionel Sambuc 9*f4a2713aSLionel Sambuc struct s0 { 10*f4a2713aSLionel Sambuc char f1; 11*f4a2713aSLionel Sambuc unsigned f2 : 32; 12*f4a2713aSLionel Sambuc char f3; 13*f4a2713aSLionel Sambuc }; 14*f4a2713aSLionel Sambuc extern int check[sizeof(struct s0) == 6 ? 1 : -1]; 15*f4a2713aSLionel Sambuc 16*f4a2713aSLionel Sambuc struct s1 { 17*f4a2713aSLionel Sambuc char f1; 18*f4a2713aSLionel Sambuc unsigned : 0; 19*f4a2713aSLionel Sambuc char f3; 20*f4a2713aSLionel Sambuc }; 21*f4a2713aSLionel Sambuc extern int check[sizeof(struct s1) == 5 ? 1 : -1]; 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuc struct s2 { 24*f4a2713aSLionel Sambuc char f1; 25*f4a2713aSLionel Sambuc unsigned : 0; 26*f4a2713aSLionel Sambuc unsigned f3 : 8; 27*f4a2713aSLionel Sambuc char f4; 28*f4a2713aSLionel Sambuc }; 29*f4a2713aSLionel Sambuc extern int check[sizeof(struct s2) == 6 ? 1 : -1]; 30*f4a2713aSLionel Sambuc 31*f4a2713aSLionel Sambuc struct s3 { 32*f4a2713aSLionel Sambuc char f1; 33*f4a2713aSLionel Sambuc unsigned : 0; 34*f4a2713aSLionel Sambuc unsigned f3 : 16; 35*f4a2713aSLionel Sambuc char f4; 36*f4a2713aSLionel Sambuc }; 37*f4a2713aSLionel Sambuc extern int check[sizeof(struct s3) == 8 ? 1 : -1]; 38*f4a2713aSLionel Sambuc extern int check[offsetof(struct s3, f4) == 6 ? 1 : -1]; 39*f4a2713aSLionel Sambuc 40*f4a2713aSLionel Sambuc struct s4 { 41*f4a2713aSLionel Sambuc char f1; 42*f4a2713aSLionel Sambuc unsigned f2 : 8; 43*f4a2713aSLionel Sambuc char f3; 44*f4a2713aSLionel Sambuc }; 45*f4a2713aSLionel Sambuc extern int check[sizeof(struct s4) == 4 ? 1 : -1]; 46*f4a2713aSLionel Sambuc extern int check[offsetof(struct s4, f3) == 2 ? 1 : -1]; 47