aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGenCXX/vtable-layout.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2010-03-03 04:58:02 +0000
committerAnders Carlsson <andersca@mac.com>2010-03-03 04:58:02 +0000
commitce57dd5f9ff5bd6cebe3c94ae48eaf166ea50a23 (patch)
tree6907fa08fc852fa2c5b52160ff468fd9c1b76090 /test/CodeGenCXX/vtable-layout.cpp
parent4e6ba4be8ddeca2978da6b9bae02cbe9594f2ef4 (diff)
Fix a bug with base offset merging that Devang noticed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97641 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/vtable-layout.cpp')
-rw-r--r--test/CodeGenCXX/vtable-layout.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/test/CodeGenCXX/vtable-layout.cpp b/test/CodeGenCXX/vtable-layout.cpp
index 022e49661f..a65af6ed33 100644
--- a/test/CodeGenCXX/vtable-layout.cpp
+++ b/test/CodeGenCXX/vtable-layout.cpp
@@ -978,3 +978,61 @@ struct D : B, C {
void D::f() { }
}
+
+namespace Test25 {
+
+// This mainly tests that we don't assert on this class hierarchy.
+
+struct V {
+ virtual void f();
+};
+
+struct A : virtual V { };
+struct B : virtual V { };
+
+// CHECK: Vtable for 'Test25::C' (11 entries).
+// CHECK-NEXT: 0 | vbase_offset (0)
+// CHECK-NEXT: 1 | vcall_offset (0)
+// CHECK-NEXT: 2 | offset_to_top (0)
+// CHECK-NEXT: 3 | Test25::C RTTI
+// CHECK-NEXT: -- (Test25::A, 0) vtable address --
+// CHECK-NEXT: -- (Test25::C, 0) vtable address --
+// CHECK-NEXT: -- (Test25::V, 0) vtable address --
+// CHECK-NEXT: 4 | void Test25::V::f()
+// CHECK-NEXT: 5 | void Test25::C::g()
+// CHECK-NEXT: 6 | vbase_offset (-8)
+// CHECK-NEXT: 7 | vcall_offset (-8)
+// CHECK-NEXT: 8 | offset_to_top (-8)
+// CHECK-NEXT: 9 | Test25::C RTTI
+// CHECK-NEXT: -- (Test25::B, 8) vtable address --
+// CHECK-NEXT: -- (Test25::V, 8) vtable address --
+// CHECK-NEXT: 10 | [unused] void Test25::V::f()
+
+// CHECK: Construction vtable for ('Test25::A', 0) in 'Test25::C' (5 entries).
+// CHECK-NEXT: 0 | vbase_offset (0)
+// CHECK-NEXT: 1 | vcall_offset (0)
+// CHECK-NEXT: 2 | offset_to_top (0)
+// CHECK-NEXT: 3 | Test25::A RTTI
+// CHECK-NEXT: -- (Test25::A, 0) vtable address --
+// CHECK-NEXT: -- (Test25::V, 0) vtable address --
+// CHECK-NEXT: 4 | void Test25::V::f()
+
+// CHECK: Construction vtable for ('Test25::B', 8) in 'Test25::C' (9 entries).
+// CHECK-NEXT: 0 | vbase_offset (-8)
+// CHECK-NEXT: 1 | vcall_offset (-8)
+// CHECK-NEXT: 2 | offset_to_top (0)
+// CHECK-NEXT: 3 | Test25::B RTTI
+// CHECK-NEXT: -- (Test25::B, 8) vtable address --
+// CHECK-NEXT: -- (Test25::V, 8) vtable address --
+// CHECK-NEXT: 4 | [unused] void Test25::V::f()
+// CHECK-NEXT: 5 | vcall_offset (0)
+// CHECK-NEXT: 6 | offset_to_top (8)
+// CHECK-NEXT: 7 | Test25::B RTTI
+// CHECK-NEXT: -- (Test25::V, 0) vtable address --
+// CHECK-NEXT: 8 | void Test25::V::f()
+struct C : A, virtual V, B {
+ virtual void g();
+};
+void C::g() { }
+
+}