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