1 // RUN: %clang_cc1 -emit-llvm-only  -triple i386-apple-darwin9 -fdump-record-layouts %s | FileCheck %s
2 // rdar://8823265
3 
4 #pragma pack(1)
5 struct _one_ms {
6         short m:9;      // size is 2
7         int q:27;       // size is 6
8         short w:13;     // size is 8
9         short e:3;      // size is 8
10         char r:4;       // size is 9
11         char t:7;       // size is 10
12         short y:16;     // size is 12
13         short u:1;      // size is 14
14         char i:2;       // size is 15
15         int a;          // size is 19
16         char o:6;       // size is 20
17         char s:2;       // size is 20
18         short d:10;     // size is 22
19         short f:4;      // size is 22
20         char b;         // size is 23
21         char g:1;       // size is 24
22         short h:13;     // size is 26
23         char j:8;       // size is 27
24         char k:5;       // size is 28
25         char c;         // size is 29
26         int l:28;       // size is 33
27         char z:7;       // size is 34
28         int x:20;       // size is 38
29 } __attribute__((__ms_struct__));
30 typedef struct _one_ms one_ms;
31 
32 static int a1[(sizeof(one_ms) == 38) - 1];
33 
34 #pragma pack(2)
35 struct _two_ms {
36         short m:9;
37         int q:27;
38         short w:13;
39         short e:3;
40         char r:4;
41         char t:7;
42         short y:16;
43         short u:1;
44         char i:2;
45         int a;
46         char o:6;
47         char s:2;
48         short d:10;
49         short f:4;
50         char b;
51         char g:1;
52         short h:13;
53         char j:8;
54         char k:5;
55         char c;
56         int l:28;
57         char z:7;
58         int x:20;
59 } __attribute__((__ms_struct__));
60 
61 typedef struct _two_ms two_ms;
62 
63 static int a2[(sizeof(two_ms) == 42) - 1];
64 
65 #pragma pack(4)
66 struct _four_ms {
67         short m:9;
68         int q:27;
69         short w:13;
70         short e:3;
71         char r:4;
72         char t:7;
73         short y:16;
74         short u:1;
75         char i:2;
76         int a;
77         char o:6;
78         char s:2;
79         short d:10;
80         short f:4;
81         char b;
82         char g:1;
83         short h:13;
84         char j:8;
85         char k:5;
86         char c;
87         int l:28;
88         char z:7;
89         int x:20;
90 } __attribute__((__ms_struct__));
91 typedef struct _four_ms four_ms;
92 
93 static int a4[(sizeof(four_ms) == 48) - 1];
94 
95 #pragma pack(8)
96 struct _eight_ms {
97         short m:9;
98         int q:27;
99         short w:13;
100         short e:3;
101         char r:4;
102         char t:7;
103         short y:16;
104         short u:1;
105         char i:2;
106         int a;
107         char o:6;
108         char s:2;
109         short d:10;
110         short f:4;
111         char b;
112         char g:1;
113         short h:13;
114         char j:8;
115         char k:5;
116         char c;
117         int l:28;
118         char z:7;
119         int x:20;
120 } __attribute__((__ms_struct__));
121 
122 typedef struct _eight_ms eight_ms;
123 
124 static int a8[(sizeof(eight_ms) == 48) - 1];
125 
126 // rdar://15926990
127 #pragma pack(2)
128 struct test0 {
129   unsigned long a : 8;
130   unsigned long b : 8;
131   unsigned long c : 8;
132   unsigned long d : 10;
133   unsigned long e : 1;
134 } __attribute__((__ms_struct__));
135 
136 // CHECK:             0 | struct test0
137 // CHECK-NEXT:    0:0-7 |   unsigned long a
138 // CHECK-NEXT:    1:0-7 |   unsigned long b
139 // CHECK-NEXT:    2:0-7 |   unsigned long c
140 // CHECK-NEXT:    4:0-9 |   unsigned long d
141 // CHECK-NEXT:    5:2-2 |   unsigned long e
142 // CHECK-NEXT:          | [sizeof=8, align=2]
143 
144 static int test0[(sizeof(struct test0) == 8) ? 1 : -1];
145