[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Layout / ms-x86-declspec-empty_bases.cpp
blobcc13a980cb5dbd3bbe18b1d6dfa36eb34ae4ca4f
1 // RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fms-extensions -fdump-record-layouts -fsyntax-only %s 2>/dev/null \
2 // RUN: | FileCheck %s
3 // RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple x86_64-pc-win32 -fms-extensions -fdump-record-layouts -fsyntax-only %s 2>/dev/null \
4 // RUN: | FileCheck %s
6 namespace test1 {
8 struct A {
9 int a;
11 struct B {
12 int b;
14 struct C {};
15 struct __declspec(align(16)) D {};
16 struct __declspec(empty_bases) X : A, D, B, C {
19 // CHECK: *** Dumping AST Record Layout
20 // CHECK-NEXT: 0 | struct test1::A
21 // CHECK-NEXT: 0 | int a
22 // CHECK-NEXT: | [sizeof=4, align=4,
23 // CHECK-NEXT: | nvsize=4, nvalign=4]
25 // CHECK: *** Dumping AST Record Layout
26 // CHECK-NEXT: 0 | struct test1::D (empty)
27 // CHECK-NEXT: | [sizeof=16, align=16,
28 // CHECK-NEXT: | nvsize=0, nvalign=16]
30 // CHECK: *** Dumping AST Record Layout
31 // CHECK-NEXT: 0 | struct test1::B
32 // CHECK-NEXT: 0 | int b
33 // CHECK-NEXT: | [sizeof=4, align=4,
34 // CHECK-NEXT: | nvsize=4, nvalign=4]
36 // CHECK: *** Dumping AST Record Layout
37 // CHECK-NEXT: 0 | struct test1::C (empty)
38 // CHECK-NEXT: | [sizeof=1, align=1,
39 // CHECK-NEXT: | nvsize=0, nvalign=1]
41 // CHECK: *** Dumping AST Record Layout
42 // CHECK-NEXT: 0 | struct test1::X
43 // CHECK-NEXT: 0 | struct test1::A (base)
44 // CHECK-NEXT: 0 | int a
45 // CHECK-NEXT: 0 | struct test1::D (base) (empty)
46 // CHECK-NEXT: 0 | struct test1::C (base) (empty)
47 // CHECK-NEXT: 4 | struct test1::B (base)
48 // CHECK-NEXT: 4 | int b
49 // CHECK-NEXT: | [sizeof=16, align=16,
50 // CHECK-NEXT: | nvsize=16, nvalign=16]
52 int _ = sizeof(X);
55 namespace test2 {
56 struct A {
57 int a;
59 struct __declspec(empty_bases) B {};
60 struct C : A {
61 B b;
64 struct D {};
65 struct E {
66 int e;
68 struct F : D, E {};
70 struct G : C, F {};
72 int _ = sizeof(G);
74 // CHECK: *** Dumping AST Record Layout
75 // CHECK-NEXT: 0 | struct test2::A
76 // CHECK-NEXT: 0 | int a
77 // CHECK-NEXT: | [sizeof=4, align=4,
78 // CHECK-NEXT: | nvsize=4, nvalign=4]
80 // CHECK: *** Dumping AST Record Layout
81 // CHECK-NEXT: 0 | struct test2::B (empty)
82 // CHECK-NEXT: | [sizeof=1, align=1,
83 // CHECK-NEXT: | nvsize=0, nvalign=1]
85 // CHECK: *** Dumping AST Record Layout
86 // CHECK-NEXT: 0 | struct test2::C
87 // CHECK-NEXT: 0 | struct test2::A (base)
88 // CHECK-NEXT: 0 | int a
89 // CHECK-NEXT: 4 | struct test2::B b (empty)
90 // CHECK-NEXT: | [sizeof=8, align=4,
91 // CHECK-NEXT: | nvsize=8, nvalign=4]
93 // CHECK: *** Dumping AST Record Layout
94 // CHECK-NEXT: 0 | struct test2::D (empty)
95 // CHECK-NEXT: | [sizeof=1, align=1,
96 // CHECK-NEXT: | nvsize=0, nvalign=1]
98 // CHECK: *** Dumping AST Record Layout
99 // CHECK-NEXT: 0 | struct test2::E
100 // CHECK-NEXT: 0 | int e
101 // CHECK-NEXT: | [sizeof=4, align=4,
102 // CHECK-NEXT: | nvsize=4, nvalign=4]
104 // CHECK: *** Dumping AST Record Layout
105 // CHECK-NEXT: 0 | struct test2::F
106 // CHECK-NEXT: 0 | struct test2::D (base) (empty)
107 // CHECK-NEXT: 0 | struct test2::E (base)
108 // CHECK-NEXT: 0 | int e
109 // CHECK-NEXT: | [sizeof=4, align=4,
110 // CHECK-NEXT: | nvsize=4, nvalign=4]
112 // CHECK: *** Dumping AST Record Layout
113 // CHECK-NEXT: 0 | struct test2::G
114 // CHECK-NEXT: 0 | struct test2::C (base)
115 // CHECK-NEXT: 0 | struct test2::A (base)
116 // CHECK-NEXT: 0 | int a
117 // CHECK-NEXT: 4 | struct test2::B b (empty)
118 // CHECK-NEXT: 8 | struct test2::F (base)
119 // CHECK-NEXT: 8 | struct test2::D (base) (empty)
120 // CHECK-NEXT: 8 | struct test2::E (base)
121 // CHECK-NEXT: 8 | int e
122 // CHECK-NEXT: | [sizeof=12, align=4,
123 // CHECK-NEXT: | nvsize=12, nvalign=4]
126 namespace test3 {
127 struct A {
128 int a;
130 struct B {};
131 struct C : A {
132 B b;
135 struct D {};
136 struct E {
137 int e;
139 struct F : D, E {};
141 struct __declspec(empty_bases) G : C, F {};
143 int _ = sizeof(G);
145 // CHECK: *** Dumping AST Record Layout
146 // CHECK-NEXT: 0 | struct test3::A
147 // CHECK-NEXT: 0 | int a
148 // CHECK-NEXT: | [sizeof=4, align=4,
149 // CHECK-NEXT: | nvsize=4, nvalign=4]
151 // CHECK: *** Dumping AST Record Layout
152 // CHECK-NEXT: 0 | struct test3::B (empty)
153 // CHECK-NEXT: | [sizeof=1, align=1,
154 // CHECK-NEXT: | nvsize=0, nvalign=1]
156 // CHECK: *** Dumping AST Record Layout
157 // CHECK-NEXT: 0 | struct test3::C
158 // CHECK-NEXT: 0 | struct test3::A (base)
159 // CHECK-NEXT: 0 | int a
160 // CHECK-NEXT: 4 | struct test3::B b (empty)
161 // CHECK-NEXT: | [sizeof=8, align=4,
162 // CHECK-NEXT: | nvsize=8, nvalign=4]
164 // CHECK: *** Dumping AST Record Layout
165 // CHECK-NEXT: 0 | struct test3::D (empty)
166 // CHECK-NEXT: | [sizeof=1, align=1,
167 // CHECK-NEXT: | nvsize=0, nvalign=1]
169 // CHECK: *** Dumping AST Record Layout
170 // CHECK-NEXT: 0 | struct test3::E
171 // CHECK-NEXT: 0 | int e
172 // CHECK-NEXT: | [sizeof=4, align=4,
173 // CHECK-NEXT: | nvsize=4, nvalign=4]
175 // CHECK: *** Dumping AST Record Layout
176 // CHECK-NEXT: 0 | struct test3::F
177 // CHECK-NEXT: 0 | struct test3::D (base) (empty)
178 // CHECK-NEXT: 0 | struct test3::E (base)
179 // CHECK-NEXT: 0 | int e
180 // CHECK-NEXT: | [sizeof=4, align=4,
181 // CHECK-NEXT: | nvsize=4, nvalign=4]
183 // CHECK: *** Dumping AST Record Layout
184 // CHECK-NEXT: 0 | struct test3::G
185 // CHECK-NEXT: 0 | struct test3::C (base)
186 // CHECK-NEXT: 0 | struct test3::A (base)
187 // CHECK-NEXT: 0 | int a
188 // CHECK-NEXT: 4 | struct test3::B b (empty)
189 // CHECK-NEXT: 8 | struct test3::F (base)
190 // CHECK-NEXT: 8 | struct test3::D (base) (empty)
191 // CHECK-NEXT: 8 | struct test3::E (base)
192 // CHECK-NEXT: 8 | int e
193 // CHECK-NEXT: | [sizeof=12, align=4,
194 // CHECK-NEXT: | nvsize=12, nvalign=4]
197 namespace test4 {
198 struct A {
199 int a;
201 struct B {};
202 struct C : A {
203 B b;
206 struct __declspec(empty_bases) D {};
207 struct E {
208 int e;
210 struct F : D, E {};
212 struct G : C, F {};
214 int _ = sizeof(G);
216 // CHECK: *** Dumping AST Record Layout
217 // CHECK-NEXT: 0 | struct test4::A
218 // CHECK-NEXT: 0 | int a
219 // CHECK-NEXT: | [sizeof=4, align=4,
220 // CHECK-NEXT: | nvsize=4, nvalign=4]
222 // CHECK: *** Dumping AST Record Layout
223 // CHECK-NEXT: 0 | struct test4::B (empty)
224 // CHECK-NEXT: | [sizeof=1, align=1,
225 // CHECK-NEXT: | nvsize=0, nvalign=1]
227 // CHECK: *** Dumping AST Record Layout
228 // CHECK-NEXT: 0 | struct test4::C
229 // CHECK-NEXT: 0 | struct test4::A (base)
230 // CHECK-NEXT: 0 | int a
231 // CHECK-NEXT: 4 | struct test4::B b (empty)
232 // CHECK-NEXT: | [sizeof=8, align=4,
233 // CHECK-NEXT: | nvsize=8, nvalign=4]
235 // CHECK: *** Dumping AST Record Layout
236 // CHECK-NEXT: 0 | struct test4::D (empty)
237 // CHECK-NEXT: | [sizeof=1, align=1,
238 // CHECK-NEXT: | nvsize=0, nvalign=1]
240 // CHECK: *** Dumping AST Record Layout
241 // CHECK-NEXT: 0 | struct test4::E
242 // CHECK-NEXT: 0 | int e
243 // CHECK-NEXT: | [sizeof=4, align=4,
244 // CHECK-NEXT: | nvsize=4, nvalign=4]
246 // CHECK: *** Dumping AST Record Layout
247 // CHECK-NEXT: 0 | struct test4::F
248 // CHECK-NEXT: 0 | struct test4::D (base) (empty)
249 // CHECK-NEXT: 0 | struct test4::E (base)
250 // CHECK-NEXT: 0 | int e
251 // CHECK-NEXT: | [sizeof=4, align=4,
252 // CHECK-NEXT: | nvsize=4, nvalign=4]
254 // CHECK: *** Dumping AST Record Layout
255 // CHECK-NEXT: 0 | struct test4::G
256 // CHECK-NEXT: 0 | struct test4::C (base)
257 // CHECK-NEXT: 0 | struct test4::A (base)
258 // CHECK-NEXT: 0 | int a
259 // CHECK-NEXT: 4 | struct test4::B b (empty)
260 // CHECK-NEXT: 8 | struct test4::F (base)
261 // CHECK-NEXT: 8 | struct test4::D (base) (empty)
262 // CHECK-NEXT: 8 | struct test4::E (base)
263 // CHECK-NEXT: 8 | int e
264 // CHECK-NEXT: | [sizeof=12, align=4,
265 // CHECK-NEXT: | nvsize=12, nvalign=4]