blob: e736eaf095d0ea1665c18bf41ee5dd9e9b1805ee [file] [log] [blame]
Warren Huntbd1b0c62013-10-14 19:08:58 +00001// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts -fsyntax-only -cxx-abi microsoft %s 2>&1 \
2// RUN: | FileCheck %s
3
4extern "C" int printf(const char *fmt, ...);
5
6struct B0 { int a; B0() : a(0xf00000B0) { printf("B0 = %p\n", this); } };
7struct B1 { int a; B1() : a(0xf00000B1) { printf("B1 = %p\n", this); } };
8struct B2 { B2() { printf("B2 = %p\n", this); } virtual void g() { printf("B2"); } };
9struct B3 : virtual B1 { B3() { printf("B3 = %p\n", this); } };
10struct B4 : virtual B1 { B4() { printf("B4 = %p\n", this); } virtual void g() { printf("B4"); } };
11
12struct A : B0, virtual B1 {
13 __declspec(align(16)) int a;
14 A() : a(0xf000000A) { printf(" A = %p\n\n", this); }
15 virtual void f() { printf("A"); }
16};
17
18// CHECK: *** Dumping AST Record Layout
19// CHECK: 0 | struct A
20// CHECK: 0 | (A vftable pointer)
21// CHECK: 16 | struct B0 (base)
22// CHECK: 16 | int a
23// CHECK: 20 | (A vbtable pointer)
24// CHECK: 48 | int a
25// CHECK: 64 | struct B1 (virtual base)
26// CHECK: 64 | int a
27// CHECK: | [sizeof=80, align=16
28// CHECK: | nvsize=64, nvalign=16]
29
30struct B : B2, B0, virtual B1 {
31 __declspec(align(16)) int a;
32 B() : a(0xf000000B) { printf(" B = %p\n\n", this); }
33 virtual void f() { printf("B"); }
34};
35
36// CHECK: *** Dumping AST Record Layout
37// CHECK: 0 | struct B
38// CHECK: 0 | struct B2 (primary base)
39// CHECK: 0 | (B2 vftable pointer)
40// CHECK: 4 | struct B0 (base)
41// CHECK: 4 | int a
42// CHECK: 8 | (B vbtable pointer)
43// CHECK: 32 | int a
44// CHECK: 48 | struct B1 (virtual base)
45// CHECK: 48 | int a
46// CHECK: | [sizeof=64, align=16
47// CHECK: | nvsize=48, nvalign=16]
48
49struct C : B3, B0, virtual B1 {
50 __declspec(align(16)) int a;
51 C() : a(0xf000000C) { printf(" C = %p\n\n", this); }
52 virtual void f() { printf("C"); }
53};
54
55// CHECK: *** Dumping AST Record Layout
56// CHECK: 0 | struct C
57// CHECK: 0 | (C vftable pointer)
58// CHECK: 16 | struct B3 (base)
59// CHECK: 16 | (B3 vbtable pointer)
60// CHECK: 20 | struct B0 (base)
61// CHECK: 20 | int a
62// CHECK: 32 | int a
63// CHECK: 48 | struct B1 (virtual base)
64// CHECK: 48 | int a
65// CHECK: | [sizeof=64, align=16
66// CHECK: | nvsize=48, nvalign=16]
67
68struct D : B4, B0, virtual B1 {
69 __declspec(align(16)) int a;
70 D() : a(0xf000000D) { printf(" D = %p\n\n", this); }
71 virtual void f() { printf("D"); }
72};
73
74// CHECK: *** Dumping AST Record Layout
75// CHECK: 0 | struct D
76// CHECK: 0 | struct B4 (primary base)
77// CHECK: 0 | (B4 vftable pointer)
78// CHECK: 4 | (B4 vbtable pointer)
79// CHECK: 8 | struct B0 (base)
80// CHECK: 8 | int a
81// CHECK: 16 | int a
82// CHECK: 32 | struct B1 (virtual base)
83// CHECK: 32 | int a
84// CHECK: | [sizeof=48, align=16
85// CHECK: | nvsize=32, nvalign=16]
86
87int a[
88sizeof(A)+
89sizeof(B)+
90sizeof(C)+
91sizeof(D)];