[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Layout / ms-x86-empty-base-after-base-with-vbptr.cpp
blob224594ead408e43ccaa9254aa4206ea6ebf6d714
1 // RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts %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 %s 2>/dev/null \
4 // RUN: | FileCheck %s -check-prefix CHECK-X64
7 struct U { char a; };
8 struct V { };
9 struct W { };
10 struct X : virtual V { char a; };
11 struct Y : virtual V { char a; };
12 struct Z : Y { };
14 struct A : X, W { char a; };
16 // CHECK: *** Dumping AST Record Layout
17 // CHECK: *** Dumping AST Record Layout
18 // CHECK: *** Dumping AST Record Layout
19 // CHECK: *** Dumping AST Record Layout
20 // CHECK-NEXT: 0 | struct A
21 // CHECK-NEXT: 0 | struct X (base)
22 // CHECK-NEXT: 0 | (X vbtable pointer)
23 // CHECK-NEXT: 4 | char a
24 // CHECK-NEXT: 9 | struct W (base) (empty)
25 // CHECK-NEXT: 9 | char a
26 // CHECK-NEXT: 12 | struct V (virtual base) (empty)
27 // CHECK-NEXT: | [sizeof=12, align=4
28 // CHECK-NEXT: | nvsize=12, nvalign=4]
29 // CHECK-X64: *** Dumping AST Record Layout
30 // CHECK-X64: *** Dumping AST Record Layout
31 // CHECK-X64: *** Dumping AST Record Layout
32 // CHECK-X64: *** Dumping AST Record Layout
33 // CHECK-X64-NEXT: 0 | struct A
34 // CHECK-X64-NEXT: 0 | struct X (base)
35 // CHECK-X64-NEXT: 0 | (X vbtable pointer)
36 // CHECK-X64-NEXT: 8 | char a
37 // CHECK-X64-NEXT: 17 | struct W (base) (empty)
38 // CHECK-X64-NEXT: 17 | char a
39 // CHECK-X64-NEXT: 24 | struct V (virtual base) (empty)
40 // CHECK-X64-NEXT: | [sizeof=24, align=8
41 // CHECK-X64-NEXT: | nvsize=24, nvalign=8]
43 struct B : X, U, W { char a; };
45 // CHECK: *** Dumping AST Record Layout
46 // CHECK: *** Dumping AST Record Layout
47 // CHECK-NEXT: 0 | struct B
48 // CHECK-NEXT: 0 | struct X (base)
49 // CHECK-NEXT: 0 | (X vbtable pointer)
50 // CHECK-NEXT: 4 | char a
51 // CHECK-NEXT: 8 | struct U (base)
52 // CHECK-NEXT: 8 | char a
53 // CHECK-NEXT: 9 | struct W (base) (empty)
54 // CHECK-NEXT: 9 | char a
55 // CHECK-NEXT: 12 | struct V (virtual base) (empty)
56 // CHECK-NEXT: | [sizeof=12, align=4
57 // CHECK-NEXT: | nvsize=12, nvalign=4]
58 // CHECK-X64: *** Dumping AST Record Layout
59 // CHECK-X64: *** Dumping AST Record Layout
60 // CHECK-X64-NEXT: 0 | struct B
61 // CHECK-X64-NEXT: 0 | struct X (base)
62 // CHECK-X64-NEXT: 0 | (X vbtable pointer)
63 // CHECK-X64-NEXT: 8 | char a
64 // CHECK-X64-NEXT: 16 | struct U (base)
65 // CHECK-X64-NEXT: 16 | char a
66 // CHECK-X64-NEXT: 17 | struct W (base) (empty)
67 // CHECK-X64-NEXT: 17 | char a
68 // CHECK-X64-NEXT: 24 | struct V (virtual base) (empty)
69 // CHECK-X64-NEXT: | [sizeof=24, align=8
70 // CHECK-X64-NEXT: | nvsize=24, nvalign=8]
72 struct C : X, V, W { char a; };
74 // CHECK: *** Dumping AST Record Layout
75 // CHECK-NEXT: 0 | struct C
76 // CHECK-NEXT: 0 | struct X (base)
77 // CHECK-NEXT: 0 | (X vbtable pointer)
78 // CHECK-NEXT: 4 | char a
79 // CHECK-NEXT: 9 | struct V (base) (empty)
80 // CHECK-NEXT: 10 | struct W (base) (empty)
81 // CHECK-NEXT: 10 | char a
82 // CHECK-NEXT: 12 | struct V (virtual base) (empty)
83 // CHECK-NEXT: | [sizeof=12, align=4
84 // CHECK-NEXT: | nvsize=12, nvalign=4]
85 // CHECK-X64: *** Dumping AST Record Layout
86 // CHECK-X64-NEXT: 0 | struct C
87 // CHECK-X64-NEXT: 0 | struct X (base)
88 // CHECK-X64-NEXT: 0 | (X vbtable pointer)
89 // CHECK-X64-NEXT: 8 | char a
90 // CHECK-X64-NEXT: 17 | struct V (base) (empty)
91 // CHECK-X64-NEXT: 18 | struct W (base) (empty)
92 // CHECK-X64-NEXT: 18 | char a
93 // CHECK-X64-NEXT: 24 | struct V (virtual base) (empty)
94 // CHECK-X64-NEXT: | [sizeof=24, align=8
95 // CHECK-X64-NEXT: | nvsize=24, nvalign=8]
97 struct D : X, U, V, W { char a; };
99 // CHECK: *** Dumping AST Record Layout
100 // CHECK-NEXT: 0 | struct D
101 // CHECK-NEXT: 0 | struct X (base)
102 // CHECK-NEXT: 0 | (X vbtable pointer)
103 // CHECK-NEXT: 4 | char a
104 // CHECK-NEXT: 8 | struct U (base)
105 // CHECK-NEXT: 8 | char a
106 // CHECK-NEXT: 9 | struct V (base) (empty)
107 // CHECK-NEXT: 10 | struct W (base) (empty)
108 // CHECK-NEXT: 10 | char a
109 // CHECK-NEXT: 12 | struct V (virtual base) (empty)
110 // CHECK-NEXT: | [sizeof=12, align=4
111 // CHECK-NEXT: | nvsize=12, nvalign=4]
112 // CHECK-X64: *** Dumping AST Record Layout
113 // CHECK-X64-NEXT: 0 | struct D
114 // CHECK-X64-NEXT: 0 | struct X (base)
115 // CHECK-X64-NEXT: 0 | (X vbtable pointer)
116 // CHECK-X64-NEXT: 8 | char a
117 // CHECK-X64-NEXT: 16 | struct U (base)
118 // CHECK-X64-NEXT: 16 | char a
119 // CHECK-X64-NEXT: 17 | struct V (base) (empty)
120 // CHECK-X64-NEXT: 18 | struct W (base) (empty)
121 // CHECK-X64-NEXT: 18 | char a
122 // CHECK-X64-NEXT: 24 | struct V (virtual base) (empty)
123 // CHECK-X64-NEXT: | [sizeof=24, align=8
124 // CHECK-X64-NEXT: | nvsize=24, nvalign=8]
126 struct E : X, U, Y, V, W { char a; };
128 // CHECK: *** Dumping AST Record Layout
129 // CHECK: *** Dumping AST Record Layout
130 // CHECK-NEXT: 0 | struct E
131 // CHECK-NEXT: 0 | struct X (base)
132 // CHECK-NEXT: 0 | (X vbtable pointer)
133 // CHECK-NEXT: 4 | char a
134 // CHECK-NEXT: 8 | struct U (base)
135 // CHECK-NEXT: 8 | char a
136 // CHECK-NEXT: 12 | struct Y (base)
137 // CHECK-NEXT: 12 | (Y vbtable pointer)
138 // CHECK-NEXT: 16 | char a
139 // CHECK-NEXT: 21 | struct V (base) (empty)
140 // CHECK-NEXT: 22 | struct W (base) (empty)
141 // CHECK-NEXT: 22 | char a
142 // CHECK-NEXT: 24 | struct V (virtual base) (empty)
143 // CHECK-NEXT: | [sizeof=24, align=4
144 // CHECK-NEXT: | nvsize=24, nvalign=4]
145 // CHECK-X64: *** Dumping AST Record Layout
146 // CHECK-X64: *** Dumping AST Record Layout
147 // CHECK-X64-NEXT: 0 | struct E
148 // CHECK-X64-NEXT: 0 | struct X (base)
149 // CHECK-X64-NEXT: 0 | (X vbtable pointer)
150 // CHECK-X64-NEXT: 8 | char a
151 // CHECK-X64-NEXT: 16 | struct U (base)
152 // CHECK-X64-NEXT: 16 | char a
153 // CHECK-X64-NEXT: 24 | struct Y (base)
154 // CHECK-X64-NEXT: 24 | (Y vbtable pointer)
155 // CHECK-X64-NEXT: 32 | char a
156 // CHECK-X64-NEXT: 41 | struct V (base) (empty)
157 // CHECK-X64-NEXT: 42 | struct W (base) (empty)
158 // CHECK-X64-NEXT: 42 | char a
159 // CHECK-X64-NEXT: 48 | struct V (virtual base) (empty)
160 // CHECK-X64-NEXT: | [sizeof=48, align=8
161 // CHECK-X64-NEXT: | nvsize=48, nvalign=8]
163 struct F : Z, W { char a; };
165 // CHECK: *** Dumping AST Record Layout
166 // CHECK: *** Dumping AST Record Layout
167 // CHECK-NEXT: 0 | struct F
168 // CHECK-NEXT: 0 | struct Z (base)
169 // CHECK-NEXT: 0 | struct Y (base)
170 // CHECK-NEXT: 0 | (Y vbtable pointer)
171 // CHECK-NEXT: 4 | char a
172 // CHECK-NEXT: 9 | struct W (base) (empty)
173 // CHECK-NEXT: 9 | char a
174 // CHECK-NEXT: 12 | struct V (virtual base) (empty)
175 // CHECK-NEXT: | [sizeof=12, align=4
176 // CHECK-NEXT: | nvsize=12, nvalign=4]
177 // CHECK-X64: *** Dumping AST Record Layout
178 // CHECK-X64: *** Dumping AST Record Layout
179 // CHECK-X64-NEXT: 0 | struct F
180 // CHECK-X64-NEXT: 0 | struct Z (base)
181 // CHECK-X64-NEXT: 0 | struct Y (base)
182 // CHECK-X64-NEXT: 0 | (Y vbtable pointer)
183 // CHECK-X64-NEXT: 8 | char a
184 // CHECK-X64-NEXT: 17 | struct W (base) (empty)
185 // CHECK-X64-NEXT: 17 | char a
186 // CHECK-X64-NEXT: 24 | struct V (virtual base) (empty)
187 // CHECK-X64-NEXT: | [sizeof=24, align=8
188 // CHECK-X64-NEXT: | nvsize=24, nvalign=8]
190 struct G : X, W, Y, V { char a; };
192 // CHECK: *** Dumping AST Record Layout
193 // CHECK-NEXT: 0 | struct G
194 // CHECK-NEXT: 0 | struct X (base)
195 // CHECK-NEXT: 0 | (X vbtable pointer)
196 // CHECK-NEXT: 4 | char a
197 // CHECK-NEXT: 9 | struct W (base) (empty)
198 // CHECK-NEXT: 12 | struct Y (base)
199 // CHECK-NEXT: 12 | (Y vbtable pointer)
200 // CHECK-NEXT: 16 | char a
201 // CHECK-NEXT: 21 | struct V (base) (empty)
202 // CHECK-NEXT: 21 | char a
203 // CHECK-NEXT: 24 | struct V (virtual base) (empty)
204 // CHECK-NEXT: | [sizeof=24, align=4
205 // CHECK-NEXT: | nvsize=24, nvalign=4]
206 // CHECK-X64: *** Dumping AST Record Layout
207 // CHECK-X64-NEXT: 0 | struct G
208 // CHECK-X64-NEXT: 0 | struct X (base)
209 // CHECK-X64-NEXT: 0 | (X vbtable pointer)
210 // CHECK-X64-NEXT: 8 | char a
211 // CHECK-X64-NEXT: 17 | struct W (base) (empty)
212 // CHECK-X64-NEXT: 24 | struct Y (base)
213 // CHECK-X64-NEXT: 24 | (Y vbtable pointer)
214 // CHECK-X64-NEXT: 32 | char a
215 // CHECK-X64-NEXT: 41 | struct V (base) (empty)
216 // CHECK-X64-NEXT: 41 | char a
217 // CHECK-X64-NEXT: 48 | struct V (virtual base) (empty)
218 // CHECK-X64-NEXT: | [sizeof=48, align=8
219 // CHECK-X64-NEXT: | nvsize=48, nvalign=8]
221 int a[
222 sizeof(A)+
223 sizeof(B)+
224 sizeof(C)+
225 sizeof(D)+
226 sizeof(E)+
227 sizeof(F)+
228 sizeof(G)];