ms_struct-bitfield.c
2.96 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
// RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-apple-darwin9 %s | FileCheck %s
// RUN: %clang_cc1 -emit-llvm -o - -triple thumbv7-apple-ios -target-abi apcs-gnu %s | FileCheck %s -check-prefix=CHECK-ARM
// rdar://8823265
// Note that we're declaring global variables with these types,
// triggering both Sema and IRGen struct layout.
#define ATTR __attribute__((__ms_struct__))
struct
{
char foo;
long : 0;
char bar;
} ATTR t1;
int s1 = sizeof(t1);
// CHECK: @s1 = global i32 2
// CHECK-ARM: @s1 = global i32 2
struct
{
char foo;
long : 0;
char : 0;
int : 0;
char bar;
} ATTR t2;
int s2 = sizeof(t2);
// CHECK: @s2 = global i32 2
// CHECK-ARM: @s2 = global i32 2
struct
{
char foo;
long : 0;
char : 0;
int : 0;
char bar;
long : 0;
char : 0;
} ATTR t3;
int s3 = sizeof(t3);
// CHECK: @s3 = global i32 2
// CHECK-ARM: @s3 = global i32 2
struct
{
long : 0;
char bar;
} ATTR t4;
int s4 = sizeof(t4);
// CHECK: @s4 = global i32 1
// CHECK-ARM: @s4 = global i32 1
struct
{
long : 0;
long : 0;
char : 0;
char bar;
} ATTR t5;
int s5 = sizeof(t5);
// CHECK: @s5 = global i32 1
// CHECK-ARM: @s5 = global i32 1
struct
{
long : 0;
long : 0;
char : 0;
char bar;
} ATTR t6;
int s6 = sizeof(t6);
// CHECK: @s6 = global i32 1
// CHECK-ARM: @s6 = global i32 1
struct
{
char foo;
long : 0;
int : 0;
char bar;
char bar1;
long : 0;
char bar2;
char bar3;
char : 0;
char bar4;
char bar5;
char : 0;
char bar6;
char bar7;
} ATTR t7;
int s7 = sizeof(t7);
// CHECK: @s7 = global i32 9
// CHECK-ARM: @s7 = global i32 9
struct
{
long : 0;
long : 0;
char : 0;
} ATTR t8;
int s8 = sizeof(t8);
// CHECK: @s8 = global i32 0
// CHECK-ARM: @s8 = global i32 0
struct
{
char foo;
long : 0;
int : 0;
char bar;
char bar1;
long : 0;
char bar2;
char bar3;
char : 0;
char bar4;
char bar5;
char : 0;
char bar6;
char bar7;
int i1;
char : 0;
long : 0;
char :4;
char bar8;
char : 0;
char bar9;
char bar10;
int i2;
char : 0;
long : 0;
char :4;
} ATTR t9;
int s9 = sizeof(t9);
// CHECK: @s9 = global i32 28
// CHECK-ARM: @s9 = global i32 28
struct
{
char foo: 8;
long : 0;
char bar;
} ATTR t10;
int s10 = sizeof(t10);
// CHECK: @s10 = global i32 16
// CHECK-ARM: @s10 = global i32 8
// rdar://16041826 - ensure that ms_structs work correctly on a
// !useBitFieldTypeAlignment() target
struct {
unsigned int a : 31;
unsigned int b : 2;
unsigned int c;
} ATTR t11;
int s11 = sizeof(t11);
// CHECK: @s11 = global i32 12
// CHECK-ARM: @s11 = global i32 12
struct {
unsigned char a : 3;
unsigned char b : 4;
unsigned short c : 6;
} ATTR t12;
int s12 = sizeof(t12);
// CHECK: @s12 = global i32 4
// CHECK-ARM: @s12 = global i32 4
struct {
unsigned char a : 3;
unsigned char b : 4;
__attribute__((packed)) unsigned short c : 6;
} ATTR t13;
int s13 = sizeof(t13);
// CHECK: @s13 = global i32 4
// CHECK-ARM: @s13 = global i32 4