[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Layout / ms-x86-vfvb-sharing.cpp
blob042f9b1f878286141af4052c2aa146e9b1e7fc89
1 // RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fms-extensions -fdump-record-layouts -fsyntax-only %s 2>&1 \
2 // RUN: | FileCheck %s --strict-whitespace
3 // RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple x86_64-pc-win32 -fms-extensions -fdump-record-layouts -fsyntax-only %s 2>/dev/null \
4 // RUN: | FileCheck %s -check-prefix CHECK-X64 --strict-whitespace
6 extern "C" int printf(const char *fmt, ...);
8 struct B0 { int a; B0() : a(0xf00000B0) { printf("B0 = %p\n", this); } };
9 struct B1 { int a; B1() : a(0xf00000B1) { printf("B1 = %p\n", this); } };
10 struct B2 { B2() { printf("B2 = %p\n", this); } virtual void g() { printf("B2"); } };
11 struct B3 : virtual B1 { B3() { printf("B3 = %p\n", this); } };
12 struct B4 : virtual B1 { B4() { printf("B4 = %p\n", this); } virtual void g() { printf("B4"); } };
14 struct A : B0, virtual B1 {
15 __declspec(align(16)) int a;
16 A() : a(0xf000000A) { printf(" A = %p\n\n", this); }
17 virtual void f() { printf("A"); }
20 // CHECK-LABEL: 0 | struct A
21 // CHECK-NEXT: 0 | (A vftable pointer)
22 // CHECK-NEXT: 16 | struct B0 (base)
23 // CHECK-NEXT: 16 | int a
24 // CHECK-NEXT: 20 | (A vbtable pointer)
25 // CHECK-NEXT: 48 | int a
26 // CHECK-NEXT: 64 | struct B1 (virtual base)
27 // CHECK-NEXT: 64 | int a
28 // CHECK-NEXT: | [sizeof=80, align=16
29 // CHECK-NEXT: | nvsize=64, nvalign=16]
30 // CHECK-X64-LABEL: 0 | struct A
31 // CHECK-X64-NEXT: 0 | (A vftable pointer)
32 // CHECK-X64-NEXT: 16 | struct B0 (base)
33 // CHECK-X64-NEXT: 16 | int a
34 // CHECK-X64-NEXT: 24 | (A vbtable pointer)
35 // CHECK-X64-NEXT: 48 | int a
36 // CHECK-X64-NEXT: 64 | struct B1 (virtual base)
37 // CHECK-X64-NEXT: 64 | int a
38 // CHECK-X64-NEXT: | [sizeof=80, align=16
39 // CHECK-X64-NEXT: | nvsize=64, nvalign=16]
41 struct B : B2, B0, virtual B1 {
42 __declspec(align(16)) int a;
43 B() : a(0xf000000B) { printf(" B = %p\n\n", this); }
44 virtual void f() { printf("B"); }
47 // CHECK-LABEL: 0 | struct B{{$}}
48 // CHECK-NEXT: 0 | struct B2 (primary base)
49 // CHECK-NEXT: 0 | (B2 vftable pointer)
50 // CHECK-NEXT: 4 | struct B0 (base)
51 // CHECK-NEXT: 4 | int a
52 // CHECK-NEXT: 8 | (B vbtable pointer)
53 // CHECK-NEXT: 32 | int a
54 // CHECK-NEXT: 48 | struct B1 (virtual base)
55 // CHECK-NEXT: 48 | int a
56 // CHECK-NEXT: | [sizeof=64, align=16
57 // CHECK-NEXT: | nvsize=48, nvalign=16]
58 // CHECK-X64-LABEL: 0 | struct B{{$}}
59 // CHECK-X64-NEXT: 0 | struct B2 (primary base)
60 // CHECK-X64-NEXT: 0 | (B2 vftable pointer)
61 // CHECK-X64-NEXT: 8 | struct B0 (base)
62 // CHECK-X64-NEXT: 8 | int a
63 // CHECK-X64-NEXT: 16 | (B vbtable pointer)
64 // CHECK-X64-NEXT: 32 | int a
65 // CHECK-X64-NEXT: 48 | struct B1 (virtual base)
66 // CHECK-X64-NEXT: 48 | int a
67 // CHECK-X64-NEXT: | [sizeof=64, align=16
68 // CHECK-X64-NEXT: | nvsize=48, nvalign=16]
70 struct C : B3, B0, virtual B1 {
71 __declspec(align(16)) int a;
72 C() : a(0xf000000C) { printf(" C = %p\n\n", this); }
73 virtual void f() { printf("C"); }
76 // CHECK-LABEL: 0 | struct C
77 // CHECK-NEXT: 0 | (C vftable pointer)
78 // CHECK-NEXT: 16 | struct B3 (base)
79 // CHECK-NEXT: 16 | (B3 vbtable pointer)
80 // CHECK-NEXT: 20 | struct B0 (base)
81 // CHECK-NEXT: 20 | int a
82 // CHECK-NEXT: 32 | int a
83 // CHECK-NEXT: 48 | struct B1 (virtual base)
84 // CHECK-NEXT: 48 | int a
85 // CHECK-NEXT: | [sizeof=64, align=16
86 // CHECK-NEXT: | nvsize=48, nvalign=16]
87 // CHECK-X64-LABEL: 0 | struct C
88 // CHECK-X64-NEXT: 0 | (C vftable pointer)
89 // CHECK-X64-NEXT: 16 | struct B3 (base)
90 // CHECK-X64-NEXT: 16 | (B3 vbtable pointer)
91 // CHECK-X64-NEXT: 24 | struct B0 (base)
92 // CHECK-X64-NEXT: 24 | int a
93 // CHECK-X64-NEXT: 32 | int a
94 // CHECK-X64-NEXT: 48 | struct B1 (virtual base)
95 // CHECK-X64-NEXT: 48 | int a
96 // CHECK-X64-NEXT: | [sizeof=64, align=16
97 // CHECK-X64-NEXT: | nvsize=48, nvalign=16]
99 struct D : B4, B0, virtual B1 {
100 __declspec(align(16)) int a;
101 D() : a(0xf000000D) { printf(" D = %p\n\n", this); }
102 virtual void f() { printf("D"); }
105 // CHECK-LABEL: 0 | struct D
106 // CHECK-NEXT: 0 | struct B4 (primary base)
107 // CHECK-NEXT: 0 | (B4 vftable pointer)
108 // CHECK-NEXT: 4 | (B4 vbtable pointer)
109 // CHECK-NEXT: 8 | struct B0 (base)
110 // CHECK-NEXT: 8 | int a
111 // CHECK-NEXT: 16 | int a
112 // CHECK-NEXT: 32 | struct B1 (virtual base)
113 // CHECK-NEXT: 32 | int a
114 // CHECK-NEXT: | [sizeof=48, align=16
115 // CHECK-NEXT: | nvsize=32, nvalign=16]
116 // CHECK-X64-LABEL: 0 | struct D
117 // CHECK-X64-NEXT: 0 | struct B4 (primary base)
118 // CHECK-X64-NEXT: 0 | (B4 vftable pointer)
119 // CHECK-X64-NEXT: 8 | (B4 vbtable pointer)
120 // CHECK-X64-NEXT: 16 | struct B0 (base)
121 // CHECK-X64-NEXT: 16 | int a
122 // CHECK-X64-NEXT: 32 | int a
123 // CHECK-X64-NEXT: 48 | struct B1 (virtual base)
124 // CHECK-X64-NEXT: 48 | int a
125 // CHECK-X64-NEXT: | [sizeof=64, align=16
126 // CHECK-X64-NEXT: | nvsize=48, nvalign=16]
128 int a[
129 sizeof(A)+
130 sizeof(B)+
131 sizeof(C)+
132 sizeof(D)];