pragma-pack-2.c revision a5728872c7702ddd09537c95bc3cbd20e1f2fb09
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 8struct s0 { 9 char f0; 10 int f1; 11}; 12extern int a0[offsetof(struct s0, f1) == 4 ? 1 : -1]; 13 14#pragma pack(push, 2) 15struct s1 { 16 char f0; 17 int f1; 18}; 19extern 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) 25struct s2_0 { 26#pragma pack(pop) 27 char f0; 28 int f1; 29}; 30extern int a2_0[offsetof(struct s2_0, f1) == 2 ? 1 : -1]; 31 32struct s2_1 { 33 char f0; 34#pragma pack(push, 2) 35 int f1; 36#pragma pack(pop) 37}; 38extern int a2_1[offsetof(struct s2_1, f1) == 4 ? 1 : -1]; 39 40struct s2_2 { 41 char f0; 42 int f1; 43#pragma pack(push, 2) 44}; 45#pragma pack(pop) 46extern int a2_2[offsetof(struct s2_2, f1) == 4 ? 1 : -1]; 47 48struct 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}; 56extern int a2_3[offsetof(struct s2_3, f1) == 2 ? 1 : -1]; 57 58struct 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}; 66extern int a2_4[offsetof(struct s2_4, f1) == 4 ? 1 : -1]; 67 68#pragma pack(1) 69struct s3_0 { 70 char f0; 71 int f1; 72}; 73#pragma pack() 74struct s3_1 { 75 char f0; 76 int f1; 77}; 78extern int a3_0[offsetof(struct s3_0, f1) == 1 ? 1 : -1]; 79extern int a3_1[offsetof(struct s3_1, f1) == 4 ? 1 : -1]; 80 81// pack(0) is like pack() 82#pragma pack(1) 83struct s4_0 { 84 char f0; 85 int f1; 86}; 87#pragma pack(0) 88struct s4_1 { 89 char f0; 90 int f1; 91}; 92extern int a4_0[offsetof(struct s4_0, f1) == 1 ? 1 : -1]; 93extern int a4_1[offsetof(struct s4_1, f1) == 4 ? 1 : -1]; 94