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