1// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -fsyntax-only -verify -ffreestanding
2// expected-no-diagnostics
3// <rdar://problem/10494810> and PR9560
4// Check #pragma pack handling with bitfields.
5
6#include <stddef.h>
7#pragma pack(2)
8
9struct s0 {
10     char        f1;
11     unsigned    f2 : 32;
12     char        f3;
13};
14extern int check[sizeof(struct s0) == 6 ? 1 : -1];
15
16struct s1 {
17     char        f1;
18     unsigned       : 0;
19     char        f3;
20};
21extern int check[sizeof(struct s1) == 5 ? 1 : -1];
22
23struct s2 {
24     char        f1;
25     unsigned       : 0;
26     unsigned    f3 : 8;
27     char        f4;
28};
29extern int check[sizeof(struct s2) == 6 ? 1 : -1];
30
31struct s3 {
32     char        f1;
33     unsigned       : 0;
34     unsigned    f3 : 16;
35     char        f4;
36};
37extern int check[sizeof(struct s3) == 8 ? 1 : -1];
38extern int check[offsetof(struct s3, f4) == 6 ? 1 : -1];
39
40struct s4 {
41     char        f1;
42     unsigned    f2 : 8;
43     char        f3;
44};
45extern int check[sizeof(struct s4) == 4 ? 1 : -1];
46extern int check[offsetof(struct s4, f3) == 2 ? 1 : -1];
47