struct-packed-align.c revision abb575866059c9bb74fe4aa32372f002143fa87c
1// RUN: clang %s -fsyntax-only -verify 2 3// Packed structs. 4struct s { 5 char a; 6 int b __attribute__((packed)); 7 char c; 8 int d; 9}; 10 11extern int a1[sizeof(struct s) == 12 ? 1 : -1]; 12extern int a2[__alignof(struct s) == 4 ? 1 : -1]; 13 14struct __attribute__((packed)) packed_s { 15 char a; 16 int b __attribute__((packed)); 17 char c; 18 int d; 19}; 20 21extern int b1[sizeof(struct packed_s) == 10 ? 1 : -1]; 22extern int b2[__alignof(struct packed_s) == 1 ? 1 : -1]; 23 24struct fas { 25 char a; 26 int b[]; 27}; 28 29extern int c1[sizeof(struct fas) == 4 ? 1 : -1]; 30extern int c2[__alignof(struct fas) == 4 ? 1 : -1]; 31 32struct __attribute__((packed)) packed_fas { 33 char a; 34 int b[]; 35}; 36 37extern int d1[sizeof(struct packed_fas) == 1 ? 1 : -1]; 38extern int d2[__alignof(struct packed_fas) == 1 ? 1 : -1]; 39 40// Alignment 41 42struct __attribute__((aligned(8))) as1 { 43 char c; 44}; 45 46extern int e1[sizeof(struct as1) == 8 ? 1 : -1]; 47extern int e2[__alignof(struct as1) == 8 ? 1 : -1]; 48 49struct as2 { 50 char c; 51 int __attribute__((aligned(8))) a; 52}; 53 54extern int f1[sizeof(struct as2) == 16 ? 1 : -1]; 55extern int f2[__alignof(struct as2) == 8 ? 1 : -1]; 56 57struct __attribute__((packed)) as3 { 58 char c; 59 int a; 60 int __attribute__((aligned(8))) b; 61}; 62 63extern int g1[sizeof(struct as3) == 16 ? 1 : -1]; 64extern int g2[__alignof(struct as3) == 8 ? 1 : -1]; 65 66 67// rdar://5921025 68struct packedtest { 69 int ted_likes_cheese; 70 void *args[] __attribute__((packed)); 71}; 72