1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts -fsyntax-only %s 2>/dev/null \
2f4a2713aSLionel Sambuc // RUN: | FileCheck %s
3*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple x86_64-pc-win32 -fdump-record-layouts -fsyntax-only %s 2>/dev/null \
4f4a2713aSLionel Sambuc // RUN: | FileCheck %s
5f4a2713aSLionel Sambuc
6f4a2713aSLionel Sambuc extern "C" int printf(const char *fmt, ...);
7f4a2713aSLionel Sambuc
B0B08f4a2713aSLionel Sambuc struct __declspec(align(8)) B0 { B0() {printf("B0 : %p\n", this);} };
B1B19f4a2713aSLionel Sambuc struct __declspec(align(8)) B1 { B1() {printf("B1 : %p\n", this);} };
B2B210f4a2713aSLionel Sambuc struct __declspec(align(8)) B2 { B2() {printf("B2 : %p\n", this);} };
B3B311f4a2713aSLionel Sambuc struct __declspec(align(8)) B3 { B3() {printf("B3 : %p\n", this);} };
B4B412f4a2713aSLionel Sambuc struct __declspec(align(8)) B4 { B4() {printf("B4 : %p\n", this);} };
13f4a2713aSLionel Sambuc
C0C014f4a2713aSLionel Sambuc struct C0 { int a; C0() : a(0xf00000C0) {printf("C0 : %p\n", this);} };
C1C115f4a2713aSLionel Sambuc struct C1 { int a; C1() : a(0xf00000C1) {printf("C1 : %p\n", this);} };
C2C216f4a2713aSLionel Sambuc struct C2 { int a; C2() : a(0xf00000C2) {printf("C2 : %p\n", this);} };
C3C317f4a2713aSLionel Sambuc struct C3 { int a; C3() : a(0xf00000C3) {printf("C3 : %p\n", this);} };
C4C418f4a2713aSLionel Sambuc struct C4 { int a; C4() : a(0xf00000C4) {printf("C4 : %p\n", this);} };
19f4a2713aSLionel Sambuc
20f4a2713aSLionel Sambuc struct A : B0 {
21f4a2713aSLionel Sambuc int a;
AA22f4a2713aSLionel Sambuc A() : a(0xf000000A) {printf("X : %p\n", this);}
23f4a2713aSLionel Sambuc };
24f4a2713aSLionel Sambuc
25f4a2713aSLionel Sambuc // CHECK: *** Dumping AST Record Layout
26*0a6a1f1dSLionel Sambuc // CHECK: *** Dumping AST Record Layout
27*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct A
28*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct B0 (base) (empty)
29*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | int a
30*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | [sizeof=8, align=8
31*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | nvsize=8, nvalign=8]
32f4a2713aSLionel Sambuc
33f4a2713aSLionel Sambuc struct B : B0 {
34f4a2713aSLionel Sambuc B0 b0;
35f4a2713aSLionel Sambuc int a;
BB36f4a2713aSLionel Sambuc B() : a(0xf000000B) {printf("X : %p\n", this);}
37f4a2713aSLionel Sambuc };
38f4a2713aSLionel Sambuc
39f4a2713aSLionel Sambuc // CHECK: *** Dumping AST Record Layout
40*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct B
41*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct B0 (base) (empty)
42*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct B0 b0 (empty)
43*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | [sizeof=8, align=8
44*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | nvsize=0, nvalign=8]
45f4a2713aSLionel Sambuc // CHECK: 8 | int a
46*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | [sizeof=16, align=8
47*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | nvsize=16, nvalign=8]
48f4a2713aSLionel Sambuc
49f4a2713aSLionel Sambuc struct C : B0, B1, B2, B3, B4 {
50f4a2713aSLionel Sambuc int a;
CC51f4a2713aSLionel Sambuc C() : a(0xf000000C) {printf("X : %p\n", this);}
52f4a2713aSLionel Sambuc };
53f4a2713aSLionel Sambuc
54f4a2713aSLionel Sambuc // CHECK: *** Dumping AST Record Layout
55*0a6a1f1dSLionel Sambuc // CHECK: *** Dumping AST Record Layout
56*0a6a1f1dSLionel Sambuc // CHECK: *** Dumping AST Record Layout
57*0a6a1f1dSLionel Sambuc // CHECK: *** Dumping AST Record Layout
58*0a6a1f1dSLionel Sambuc // CHECK: *** Dumping AST Record Layout
59*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct C
60*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct B0 (base) (empty)
61*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 8 | struct B1 (base) (empty)
62*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 16 | struct B2 (base) (empty)
63*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 24 | struct B3 (base) (empty)
64*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 32 | struct B4 (base) (empty)
65*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 32 | int a
66*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | [sizeof=40, align=8
67*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | nvsize=40, nvalign=8]
68f4a2713aSLionel Sambuc
69f4a2713aSLionel Sambuc struct D {
70f4a2713aSLionel Sambuc B0 b0;
71f4a2713aSLionel Sambuc C0 c0;
72f4a2713aSLionel Sambuc C1 c1;
73f4a2713aSLionel Sambuc C2 c2;
74f4a2713aSLionel Sambuc B1 b1;
75f4a2713aSLionel Sambuc int a;
DD76f4a2713aSLionel Sambuc D() : a(0xf000000D) {printf("X : %p\n", this);}
77f4a2713aSLionel Sambuc };
78f4a2713aSLionel Sambuc
79f4a2713aSLionel Sambuc // CHECK: *** Dumping AST Record Layout
80*0a6a1f1dSLionel Sambuc // CHECK: *** Dumping AST Record Layout
81*0a6a1f1dSLionel Sambuc // CHECK: *** Dumping AST Record Layout
82*0a6a1f1dSLionel Sambuc // CHECK: *** Dumping AST Record Layout
83*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct D
84*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct B0 b0 (empty)
85*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | [sizeof=8, align=8
86*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | nvsize=0, nvalign=8]
87f4a2713aSLionel Sambuc // CHECK: 8 | struct C0 c0
88*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 8 | int a
89*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | [sizeof=4, align=4
90*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | nvsize=4, nvalign=4]
91f4a2713aSLionel Sambuc // CHECK: 12 | struct C1 c1
92*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 12 | int a
93*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | [sizeof=4, align=4
94*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | nvsize=4, nvalign=4]
95f4a2713aSLionel Sambuc // CHECK: 16 | struct C2 c2
96*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 16 | int a
97*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | [sizeof=4, align=4
98*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | nvsize=4, nvalign=4]
99f4a2713aSLionel Sambuc // CHECK: 24 | struct B1 b1 (empty)
100*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | [sizeof=8, align=8
101*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | nvsize=0, nvalign=8]
102f4a2713aSLionel Sambuc // CHECK: 32 | int a
103*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | [sizeof=40, align=8
104*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | nvsize=40, nvalign=8]
105f4a2713aSLionel Sambuc
106f4a2713aSLionel Sambuc struct E : B0, C0, C1, C2, B1 {
107f4a2713aSLionel Sambuc int a;
EE108f4a2713aSLionel Sambuc E() : a(0xf000000E) {printf("X : %p\n", this);}
109f4a2713aSLionel Sambuc };
110f4a2713aSLionel Sambuc
111f4a2713aSLionel Sambuc // CHECK: *** Dumping AST Record Layout
112*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct E
113*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct B0 (base) (empty)
114*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct C0 (base)
115*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | int a
116*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 4 | struct C1 (base)
117*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 4 | int a
118*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 8 | struct C2 (base)
119*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 8 | int a
120*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 16 | struct B1 (base) (empty)
121*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 16 | int a
122*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | [sizeof=24, align=8
123*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | nvsize=24, nvalign=8]
124f4a2713aSLionel Sambuc
125f4a2713aSLionel Sambuc struct F : C0, B0, B1, C1 {
126f4a2713aSLionel Sambuc int a;
FF127f4a2713aSLionel Sambuc F() : a(0xf000000F) {printf("X : %p\n", this);}
128f4a2713aSLionel Sambuc };
129f4a2713aSLionel Sambuc
130f4a2713aSLionel Sambuc // CHECK: *** Dumping AST Record Layout
131*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct F
132*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct C0 (base)
133*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | int a
134*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 8 | struct B0 (base) (empty)
135*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 16 | struct B1 (base) (empty)
136*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 16 | struct C1 (base)
137*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 16 | int a
138*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 20 | int a
139*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | [sizeof=24, align=8
140*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | nvsize=24, nvalign=8]
141f4a2713aSLionel Sambuc
142f4a2713aSLionel Sambuc struct G : B0, B1, B2, B3, B4 {
143f4a2713aSLionel Sambuc __declspec(align(32)) int a;
GG144f4a2713aSLionel Sambuc G() : a(0xf0000011) {printf("X : %p\n", this);}
145f4a2713aSLionel Sambuc };
146f4a2713aSLionel Sambuc
147f4a2713aSLionel Sambuc // CHECK: *** Dumping AST Record Layout
148*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct G
149*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct B0 (base) (empty)
150*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 8 | struct B1 (base) (empty)
151*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 16 | struct B2 (base) (empty)
152*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 24 | struct B3 (base) (empty)
153*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 32 | struct B4 (base) (empty)
154*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 32 | int a
155*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | [sizeof=64, align=32
156*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | nvsize=64, nvalign=32]
157f4a2713aSLionel Sambuc
158f4a2713aSLionel Sambuc struct __declspec(align(32)) H : B0, B1, B2, B3, B4 {
159f4a2713aSLionel Sambuc int a;
HH160f4a2713aSLionel Sambuc H() : a(0xf0000011) {printf("X : %p\n", this);}
161f4a2713aSLionel Sambuc };
162f4a2713aSLionel Sambuc
163f4a2713aSLionel Sambuc // CHECK: *** Dumping AST Record Layout
164*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct H
165*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct B0 (base) (empty)
166*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 8 | struct B1 (base) (empty)
167*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 16 | struct B2 (base) (empty)
168*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 24 | struct B3 (base) (empty)
169*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 32 | struct B4 (base) (empty)
170*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 32 | int a
171*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | [sizeof=64, align=32
172*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | nvsize=40, nvalign=32]
173f4a2713aSLionel Sambuc
174f4a2713aSLionel Sambuc int a[
175f4a2713aSLionel Sambuc sizeof(A)+
176f4a2713aSLionel Sambuc sizeof(B)+
177f4a2713aSLionel Sambuc sizeof(C)+
178f4a2713aSLionel Sambuc sizeof(D)+
179f4a2713aSLionel Sambuc sizeof(E)+
180f4a2713aSLionel Sambuc sizeof(F)+
181f4a2713aSLionel Sambuc sizeof(G)+
182f4a2713aSLionel Sambuc sizeof(H)];
183