pragma-pack-2.c revision cb00cc44dd6a2a24b8b46e88b9e57a12a38a626b
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#pragma pack(1)
23struct s3_0 {
24  char f0;
25  int f1;
26};
27#pragma pack()
28struct s3_1 {
29  char f0;
30  int f1;
31};
32extern int a3_0[offsetof(struct s3_0, f1) == 1 ? 1 : -1];
33extern int a3_1[offsetof(struct s3_1, f1) == 4 ? 1 : -1];
34
35// pack(0) is like pack()
36#pragma pack(1)
37struct s4_0 {
38  char f0;
39  int f1;
40};
41#pragma pack(0)
42struct s4_1 {
43  char f0;
44  int f1;
45};
46extern int a4_0[offsetof(struct s4_0, f1) == 1 ? 1 : -1];
47extern int a4_1[offsetof(struct s4_1, f1) == 4 ? 1 : -1];
48
49void f() {
50  #pragma pack(push, 2)
51  struct s5_0 {
52    char f0;
53    struct s2_4_0 {
54      int f0;
55    } f1;
56  };
57  #pragma pack(pop)
58  extern int s5_0[offsetof(struct s5_0, f1) == 2 ? 1 : -1];
59}
60