blob: 4a4c202c71addcc3eee251c2842c6a5b87655ff2 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -triple i686-apple-darwin9 %s -fsyntax-only -verify
Daniel Dunbar3b0db902008-10-16 02:34:03 +00002
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
Daniel Dunbar79cd1162009-03-06 20:45:54 +000022#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];
Eli Friedmanaa5ab262012-02-23 23:47:16 +000048
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}