1 // RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
2 // RUN: -fsyntax-only -fxl-pragma-pack %s | \
5 // RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \
6 // RUN: -fsyntax-only -fxl-pragma-pack %s | \
10 // Test the class layout when having a double which is/is not the first struct
27 int a
= sizeof(DoubleFirst
);
28 int b
= sizeof(IntFirst
);
30 // CHECK: *** Dumping AST Record Layout
31 // CHECK-NEXT: 0 | struct test1::D
32 // CHECK-NEXT: 0 | double d1
33 // CHECK-NEXT: 8 | int i1
34 // CHECK-NEXT: | [sizeof=16, dsize=16, align=4, preferredalign=8,
35 // CHECK-NEXT: | nvsize=16, nvalign=4, preferrednvalign=8]
37 // CHECK: *** Dumping AST Record Layout
38 // CHECK-NEXT: 0 | struct test1::DoubleFirst
39 // CHECK-NEXT: 0 | struct test1::D d2
40 // CHECK-NEXT: 0 | double d1
41 // CHECK-NEXT: 8 | int i1
42 // CHECK-NEXT: 16 | int i2
43 // CHECK-NEXT: | [sizeof=24, dsize=24, align=4, preferredalign=8,
44 // CHECK-NEXT: | nvsize=24, nvalign=4, preferrednvalign=8]
46 // CHECK: *** Dumping AST Record Layout
47 // CHECK-NEXT: 0 | struct test1::IntFirst
48 // CHECK-NEXT: 0 | int i3
49 // CHECK-NEXT: 4 | struct test1::D d3
50 // CHECK-NEXT: 4 | double d1
51 // CHECK-NEXT: 12 | int i1
52 // CHECK-NEXT: | [sizeof=20, dsize=20, align=4, preferredalign=4,
53 // CHECK-NEXT: | nvsize=20, nvalign=4, preferrednvalign=4]
57 // Test the class layout when having a zero-sized bitfield followed by double.
63 int a
= sizeof(Double
);
65 // CHECK: *** Dumping AST Record Layout
66 // CHECK-NEXT: 0 | struct test2::Double
67 // CHECK-NEXT: 0:- | int
68 // CHECK-NEXT: 0 | double d
69 // CHECK-NEXT: | [sizeof=8, dsize=8, align=4, preferredalign=4,
70 // CHECK-NEXT: | nvsize=8, nvalign=4, preferrednvalign=4]
74 // Test the class layout when having a double member in union.
85 int a
= sizeof(UnionStruct
);
87 // CHECK: *** Dumping AST Record Layout
88 // CHECK-NEXT: 0 | union test3::A
89 // CHECK-NEXT: 0 | int b
90 // CHECK-NEXT: 0 | double d
91 // CHECK-NEXT: | [sizeof=8, dsize=8, align=4, preferredalign=8,
92 // CHECK-NEXT: | nvsize=8, nvalign=4, preferrednvalign=8]
94 // CHECK: *** Dumping AST Record Layout
95 // CHECK-NEXT: 0 | struct test3::UnionStruct
96 // CHECK-NEXT: 0 | union test3::A a
97 // CHECK-NEXT: 0 | int b
98 // CHECK-NEXT: 0 | double d
99 // CHECK-NEXT: 8 | int i
100 // CHECK-NEXT: | [sizeof=16, dsize=16, align=4, preferredalign=8,
101 // CHECK-NEXT: | nvsize=16, nvalign=4, preferrednvalign=8]
106 // Test the class layout when having multiple base classes.
120 // CHECK: *** Dumping AST Record Layout
121 // CHECK-NEXT: 0 | struct test4::A
122 // CHECK-NEXT: 0 | int a
123 // CHECK-NEXT: | [sizeof=4, dsize=4, align=4, preferredalign=4,
124 // CHECK-NEXT: | nvsize=4, nvalign=4, preferrednvalign=4]
126 // CHECK: *** Dumping AST Record Layout
127 // CHECK-NEXT: 0 | struct test4::B
128 // CHECK-NEXT: 0 | double d
129 // CHECK-NEXT: | [sizeof=8, dsize=8, align=4, preferredalign=8,
130 // CHECK-NEXT: | nvsize=8, nvalign=4, preferrednvalign=8]
132 // CHECK: *** Dumping AST Record Layout
133 // CHECK-NEXT: 0 | class test4::S
134 // CHECK-NEXT: 0 | struct test4::A (base)
135 // CHECK-NEXT: 0 | int a
136 // CHECK-NEXT: 4 | struct test4::B (base)
137 // CHECK-NEXT: 4 | double d
138 // CHECK-NEXT: | [sizeof=12, dsize=12, align=4, preferredalign=4,
139 // CHECK-NEXT: | nvsize=12, nvalign=4, preferrednvalign=4]
146 struct EmptyDer
: Empty
{
154 struct NonEmptyDer
: NonEmpty
{
158 int a
= sizeof(EmptyDer
);
159 int b
= sizeof(NonEmptyDer
);
161 // CHECK: *** Dumping AST Record Layout
162 // CHECK-NEXT: 0 | struct test5::Empty (empty)
163 // CHECK-NEXT: | [sizeof=1, dsize=1, align=1, preferredalign=1,
164 // CHECK-NEXT: | nvsize=1, nvalign=1, preferrednvalign=1]
166 // CHECK: *** Dumping AST Record Layout
167 // CHECK-NEXT: 0 | struct test5::EmptyDer
168 // CHECK-NEXT: 0 | struct test5::Empty (base) (empty)
169 // CHECK-NEXT: 0 | double d
170 // CHECK-NEXT: | [sizeof=8, dsize=8, align=4, preferredalign=8,
171 // CHECK-NEXT: | nvsize=8, nvalign=4, preferrednvalign=8]
173 // CHECK: *** Dumping AST Record Layout
174 // CHECK-NEXT: 0 | struct test5::NonEmpty
175 // CHECK-NEXT: 0 | int i
176 // CHECK-NEXT: | [sizeof=4, dsize=4, align=4, preferredalign=4,
177 // CHECK-NEXT: | nvsize=4, nvalign=4, preferrednvalign=4]
179 // CHECK: *** Dumping AST Record Layout
180 // CHECK-NEXT: 0 | struct test5::NonEmptyDer
181 // CHECK-NEXT: 0 | struct test5::NonEmpty (base)
182 // CHECK-NEXT: 0 | int i
183 // CHECK-NEXT: 4 | double d
184 // CHECK-NEXT: | [sizeof=12, dsize=12, align=4, preferredalign=4,
185 // CHECK-NEXT: | nvsize=12, nvalign=4, preferrednvalign=4]
197 // CHECK: *** Dumping AST Record Layout
198 // CHECK-NEXT: 0 | struct test6::A::B
199 // CHECK-NEXT: 0 | double[3] d
200 // CHECK-NEXT: | [sizeof=24, dsize=24, align=4, preferredalign=8,
201 // CHECK-NEXT: | nvsize=24, nvalign=4, preferrednvalign=8]
203 // CHECK: *** Dumping AST Record Layout
204 // CHECK-NEXT: 0 | struct test6::A
205 // CHECK-NEXT: 0 | struct test6::A::B b
206 // CHECK-NEXT: 0 | double[3] d
207 // CHECK-NEXT: | [sizeof=24, dsize=24, align=4, preferredalign=8,
208 // CHECK-NEXT: | nvsize=24, nvalign=4, preferrednvalign=8]
215 long double _Complex d
[3];
221 // CHECK: *** Dumping AST Record Layout
222 // CHECK-NEXT: 0 | struct test7::A::B
223 // CHECK-NEXT: 0 | _Complex long double[3] d
224 // CHECK-NEXT: | [sizeof=48, dsize=48, align=4, preferredalign=8,
225 // CHECK-NEXT: | nvsize=48, nvalign=4, preferrednvalign=8]
227 // CHECK: *** Dumping AST Record Layout
228 // CHECK-NEXT: 0 | struct test7::A
229 // CHECK-NEXT: 0 | struct test7::A::B b
230 // CHECK-NEXT: 0 | _Complex long double[3] d
231 // CHECK-NEXT: | [sizeof=48, dsize=48, align=4, preferredalign=8,
232 // CHECK-NEXT: | nvsize=48, nvalign=4, preferrednvalign=8]
249 // CHECK: *** Dumping AST Record Layout
250 // CHECK-NEXT: 0 | struct test8::Emp (empty)
251 // CHECK-NEXT: | [sizeof=1, dsize=1, align=1, preferredalign=1,
252 // CHECK-NEXT: | nvsize=1, nvalign=1, preferrednvalign=1]
254 // CHECK: *** Dumping AST Record Layout
255 // CHECK-NEXT: 0 | struct test8::Y
256 // CHECK-NEXT: 0 | struct test8::Emp (base) (empty)
257 // CHECK-NEXT: 0 | double d
258 // CHECK-NEXT: | [sizeof=8, dsize=8, align=4, preferredalign=8,
259 // CHECK-NEXT: | nvsize=8, nvalign=4, preferrednvalign=8]
261 // CHECK: *** Dumping AST Record Layout
262 // CHECK-NEXT: 0 | struct test8::Z
263 // CHECK-NEXT: 0 | struct test8::Emp (base) (empty)
264 // CHECK-NEXT: 8 | struct test8::Y y
265 // CHECK-NEXT: 8 | struct test8::Emp (base) (empty)
266 // CHECK-NEXT: 8 | double d
267 // CHECK-NEXT: | [sizeof=16, dsize=16, align=4, preferredalign=8,
268 // CHECK-NEXT: | nvsize=16, nvalign=4, preferrednvalign=8]
273 // Test the class layout when having a zero-extent array in a base class, which
274 // renders the base class not empty.
275 struct A
{ char zea
[0]; };
277 struct B
: A
{ double d
; };
279 struct C
{ double d
; };
280 struct D
: A
, C
{ char x
; };
285 // CHECK: 0 | struct test9::B
286 // CHECK-NEXT: 0 | struct test9::A (base)
287 // CHECK-NEXT: 0 | char[0] zea
288 // CHECK-NEXT: 0 | double d
289 // CHECK-NEXT: | [sizeof=8, dsize=8, align=4, preferredalign=4,
290 // CHECK-NEXT: | nvsize=8, nvalign=4, preferrednvalign=4]
292 // CHECK: 0 | struct test9::D
293 // CHECK-NEXT: 0 | struct test9::A (base)
294 // CHECK-NEXT: 0 | char[0] zea
295 // CHECK-NEXT: 0 | struct test9::C (base)
296 // CHECK-NEXT: 0 | double d
297 // CHECK-NEXT: 8 | char x
298 // CHECK-NEXT: | [sizeof=12, dsize=9, align=4, preferredalign=4,
299 // CHECK-NEXT: | nvsize=9, nvalign=4, preferrednvalign=4]
304 struct A
{ double x
; };
309 // CHECK: 0 | struct test10::B
310 // CHECK-NEXT: 0 | struct test10::A (base)
311 // CHECK-NEXT: 0 | double x
312 // CHECK-NEXT: | [sizeof=8, dsize=8, align=4, preferredalign=8,
313 // CHECK-NEXT: | nvsize=8, nvalign=4, preferrednvalign=8]
315 } // namespace test10
318 // Test how #pragma pack and align attribute interacts with AIX `power`
322 double __attribute__((aligned(16))) d
;
327 double __attribute__((aligned(4))) d1
;
350 double __attribute__((aligned(4))) d
;
356 struct F
: public D
{
362 struct G
: public E
{
375 // CHECK: *** Dumping AST Record Layout
376 // CHECK-NEXT: 0 | struct test11::A
377 // CHECK-NEXT: 0 | char a
378 // CHECK-NEXT: 16 | double d
379 // CHECK-NEXT: 24 | int i
380 // CHECK-NEXT: | [sizeof=32, dsize=32, align=16, preferredalign=16,
381 // CHECK-NEXT: | nvsize=32, nvalign=16, preferrednvalign=16]
383 // CHECK: *** Dumping AST Record Layout
384 // CHECK-NEXT: 0 | struct test11::B
385 // CHECK-NEXT: 0 | double d1
386 // CHECK-NEXT: 8 | char a
387 // CHECK-NEXT: 12 | double d2
388 // CHECK-NEXT: | [sizeof=24, dsize=24, align=4, preferredalign=8,
389 // CHECK-NEXT: | nvsize=24, nvalign=4, preferrednvalign=8]
391 // CHECK: *** Dumping AST Record Layout
392 // CHECK-NEXT: 0 | struct test11::C
393 // CHECK-NEXT: 0 | int i
394 // CHECK-NEXT: 4 | short j
395 // CHECK-NEXT: 6 | double k
396 // CHECK-NEXT: | [sizeof=14, dsize=14, align=2, preferredalign=2,
397 // CHECK-NEXT: | nvsize=14, nvalign=2, preferrednvalign=2]
399 // CHECK: *** Dumping AST Record Layout
400 // CHECK-NEXT: 0 | struct test11::D
401 // CHECK-NEXT: 0 | double d
402 // CHECK-NEXT: 8 | short j
403 // CHECK-NEXT: 10 | int i
404 // CHECK-NEXT: | [sizeof=14, dsize=14, align=2, preferredalign=2,
405 // CHECK-NEXT: | nvsize=14, nvalign=2, preferrednvalign=2]
407 // CHECK: *** Dumping AST Record Layout
408 // CHECK-NEXT: 0 | struct test11::E
409 // CHECK-NEXT: 0 | double d
410 // CHECK-NEXT: 8 | short s
411 // CHECK-NEXT: | [sizeof=16, dsize=16, align=4, preferredalign=8,
412 // CHECK-NEXT: | nvsize=16, nvalign=4, preferrednvalign=8]
414 // CHECK: *** Dumping AST Record Layout
415 // CHECK-NEXT: 0 | struct test11::F
416 // CHECK-NEXT: 0 | struct test11::D (base)
417 // CHECK-NEXT: 0 | double d
418 // CHECK-NEXT: 8 | short j
419 // CHECK-NEXT: 10 | int i
420 // CHECK-NEXT: 16 | double d
421 // CHECK-NEXT: | [sizeof=24, dsize=24, align=4, preferredalign=4,
422 // CHECK-NEXT: | nvsize=24, nvalign=4, preferrednvalign=4]
424 // CHECK: *** Dumping AST Record Layout
425 // CHECK-NEXT: 0 | struct test11::G
426 // CHECK-NEXT: 0 | struct test11::E (base)
427 // CHECK-NEXT: 0 | double d
428 // CHECK-NEXT: 8 | short s
429 // CHECK-NEXT: 16 | int i
430 // CHECK-NEXT: | [sizeof=20, dsize=20, align=2, preferredalign=2,
431 // CHECK-NEXT: | nvsize=20, nvalign=2, preferrednvalign=2]
433 } // namespace test11