1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts -fsyntax-only %s 2>&1 \
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 -check-prefix CHECK-X64
5f4a2713aSLionel Sambuc
6f4a2713aSLionel Sambuc extern "C" int printf(const char *fmt, ...);
7f4a2713aSLionel Sambuc
B0B08f4a2713aSLionel Sambuc struct B0 { int a; B0() : a(0xf00000B0) { printf("B0 = %p\n", this); } };
B1B19f4a2713aSLionel Sambuc struct B1 { int a; B1() : a(0xf00000B1) { printf("B1 = %p\n", this); } };
B2B210f4a2713aSLionel Sambuc struct B2 { B2() { printf("B2 = %p\n", this); } virtual void g() { printf("B2"); } };
B3B311f4a2713aSLionel Sambuc struct B3 : virtual B1 { B3() { printf("B3 = %p\n", this); } };
B4B412f4a2713aSLionel Sambuc struct B4 : virtual B1 { B4() { printf("B4 = %p\n", this); } virtual void g() { printf("B4"); } };
13f4a2713aSLionel Sambuc
14f4a2713aSLionel Sambuc struct A : B0, virtual B1 {
15f4a2713aSLionel Sambuc __declspec(align(16)) int a;
AA16f4a2713aSLionel Sambuc A() : a(0xf000000A) { printf(" A = %p\n\n", this); }
fA17f4a2713aSLionel Sambuc virtual void f() { printf("A"); }
18f4a2713aSLionel Sambuc };
19f4a2713aSLionel Sambuc
20f4a2713aSLionel Sambuc // CHECK: *** Dumping AST Record Layout
21*0a6a1f1dSLionel Sambuc // CHECK: *** Dumping AST Record Layout
22*0a6a1f1dSLionel Sambuc // CHECK: *** Dumping AST Record Layout
23*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct A
24*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | (A vftable pointer)
25*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 16 | struct B0 (base)
26*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 16 | int a
27*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 20 | (A vbtable pointer)
28*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 48 | int a
29*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 64 | struct B1 (virtual base)
30*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 64 | int a
31*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | [sizeof=80, align=16
32*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | nvsize=64, nvalign=16]
33f4a2713aSLionel Sambuc // CHECK-X64: *** Dumping AST Record Layout
34*0a6a1f1dSLionel Sambuc // CHECK-X64: *** Dumping AST Record Layout
35*0a6a1f1dSLionel Sambuc // CHECK-X64: *** Dumping AST Record Layout
36*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 0 | struct A
37*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 0 | (A vftable pointer)
38*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 16 | struct B0 (base)
39*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 16 | int a
40*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 24 | (A vbtable pointer)
41*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 48 | int a
42*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 64 | struct B1 (virtual base)
43*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 64 | int a
44*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: | [sizeof=80, align=16
45*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: | nvsize=64, nvalign=16]
46f4a2713aSLionel Sambuc
47f4a2713aSLionel Sambuc struct B : B2, B0, virtual B1 {
48f4a2713aSLionel Sambuc __declspec(align(16)) int a;
BB49f4a2713aSLionel Sambuc B() : a(0xf000000B) { printf(" B = %p\n\n", this); }
fB50f4a2713aSLionel Sambuc virtual void f() { printf("B"); }
51f4a2713aSLionel Sambuc };
52f4a2713aSLionel Sambuc
53f4a2713aSLionel Sambuc // CHECK: *** Dumping AST Record Layout
54*0a6a1f1dSLionel Sambuc // CHECK: *** Dumping AST Record Layout
55*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct B
56*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct B2 (primary base)
57*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | (B2 vftable pointer)
58*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 4 | struct B0 (base)
59*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 4 | int a
60*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 8 | (B vbtable pointer)
61*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 32 | int a
62*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 48 | struct B1 (virtual base)
63*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 48 | int a
64*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | [sizeof=64, align=16
65*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | nvsize=48, nvalign=16]
66f4a2713aSLionel Sambuc // CHECK-X64: *** Dumping AST Record Layout
67*0a6a1f1dSLionel Sambuc // CHECK-X64: *** Dumping AST Record Layout
68*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 0 | struct B
69*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 0 | struct B2 (primary base)
70*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 0 | (B2 vftable pointer)
71*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 8 | struct B0 (base)
72*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 8 | int a
73*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 16 | (B vbtable pointer)
74*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 32 | int a
75*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 48 | struct B1 (virtual base)
76*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 48 | int a
77*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: | [sizeof=64, align=16
78*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: | nvsize=48, nvalign=16]
79f4a2713aSLionel Sambuc
80f4a2713aSLionel Sambuc struct C : B3, B0, virtual B1 {
81f4a2713aSLionel Sambuc __declspec(align(16)) int a;
CC82f4a2713aSLionel Sambuc C() : a(0xf000000C) { printf(" C = %p\n\n", this); }
fC83f4a2713aSLionel Sambuc virtual void f() { printf("C"); }
84f4a2713aSLionel Sambuc };
85f4a2713aSLionel Sambuc
86f4a2713aSLionel Sambuc // CHECK: *** Dumping AST Record Layout
87*0a6a1f1dSLionel Sambuc // CHECK: *** Dumping AST Record Layout
88*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct C
89*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | (C vftable pointer)
90*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 16 | struct B3 (base)
91*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 16 | (B3 vbtable pointer)
92*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 20 | struct B0 (base)
93*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 20 | int a
94*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 32 | int a
95*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 48 | struct B1 (virtual base)
96*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 48 | int a
97*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | [sizeof=64, align=16
98*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | nvsize=48, nvalign=16]
99f4a2713aSLionel Sambuc // CHECK-X64: *** Dumping AST Record Layout
100*0a6a1f1dSLionel Sambuc // CHECK-X64: *** Dumping AST Record Layout
101*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 0 | struct C
102*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 0 | (C vftable pointer)
103*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 16 | struct B3 (base)
104*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 16 | (B3 vbtable pointer)
105*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 24 | struct B0 (base)
106*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 24 | int a
107*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 32 | int a
108*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 48 | struct B1 (virtual base)
109*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 48 | int a
110*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: | [sizeof=64, align=16
111*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: | nvsize=48, nvalign=16]
112f4a2713aSLionel Sambuc
113f4a2713aSLionel Sambuc struct D : B4, B0, virtual B1 {
114f4a2713aSLionel Sambuc __declspec(align(16)) int a;
DD115f4a2713aSLionel Sambuc D() : a(0xf000000D) { printf(" D = %p\n\n", this); }
fD116f4a2713aSLionel Sambuc virtual void f() { printf("D"); }
117f4a2713aSLionel Sambuc };
118f4a2713aSLionel Sambuc
119f4a2713aSLionel Sambuc // CHECK: *** Dumping AST Record Layout
120*0a6a1f1dSLionel Sambuc // CHECK: *** Dumping AST Record Layout
121*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct D
122*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | struct B4 (primary base)
123*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 0 | (B4 vftable pointer)
124*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 4 | (B4 vbtable pointer)
125*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 8 | struct B0 (base)
126*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 8 | int a
127*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 16 | int a
128*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 32 | struct B1 (virtual base)
129*0a6a1f1dSLionel Sambuc // CHECK-NEXT: 32 | int a
130*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | [sizeof=48, align=16
131*0a6a1f1dSLionel Sambuc // CHECK-NEXT: | nvsize=32, nvalign=16]
132f4a2713aSLionel Sambuc // CHECK-X64: *** Dumping AST Record Layout
133*0a6a1f1dSLionel Sambuc // CHECK-X64: *** Dumping AST Record Layout
134*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 0 | struct D
135*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 0 | struct B4 (primary base)
136*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 0 | (B4 vftable pointer)
137*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 8 | (B4 vbtable pointer)
138*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 16 | struct B0 (base)
139*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 16 | int a
140*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 32 | int a
141*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 48 | struct B1 (virtual base)
142*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: 48 | int a
143*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: | [sizeof=64, align=16
144*0a6a1f1dSLionel Sambuc // CHECK-X64-NEXT: | nvsize=48, nvalign=16]
145f4a2713aSLionel Sambuc
146f4a2713aSLionel Sambuc int a[
147f4a2713aSLionel Sambuc sizeof(A)+
148f4a2713aSLionel Sambuc sizeof(B)+
149f4a2713aSLionel Sambuc sizeof(C)+
150f4a2713aSLionel Sambuc sizeof(D)];
151