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