pragma-pack-2.c revision 3b0db908ebd07eaa26bc90deba5e826de00fe515
1// RUN: clang -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