blob: 24bd4cd7d9221ca81b2a05ff3f07ced507b04ed6 [file] [log] [blame]
Eli Friedmana91d38a42011-12-02 02:38:48 +00001// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -fsyntax-only -verify -ffreestanding
Andy Gibbsc6e68da2012-10-19 12:44:48 +00002// expected-no-diagnostics
Eli Friedmana91d38a42011-12-02 02:38:48 +00003// <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];