summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/vtable-layout.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2010-02-27 19:21:58 +0000
committerAnders Carlsson <andersca@mac.com>2010-02-27 19:21:58 +0000
commit6a8c5b2bc266902a3d1138122ef25cbe10e1687b (patch)
treea969fc2240f6ab04fc31c2eb5c4fc22f5adb4f57 /test/CodeGenCXX/vtable-layout.cpp
parente54d1c12d7a53bea988e2b880b66faf04410c1be (diff)
Use the real base offset when calculating vbase offsets.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97338 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/vtable-layout.cpp')
-rw-r--r--test/CodeGenCXX/vtable-layout.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/CodeGenCXX/vtable-layout.cpp b/test/CodeGenCXX/vtable-layout.cpp
index 301cd58e98..75d4143d77 100644
--- a/test/CodeGenCXX/vtable-layout.cpp
+++ b/test/CodeGenCXX/vtable-layout.cpp
@@ -787,3 +787,49 @@ struct C : A, B {
void C::h() { }
}
+
+namespace Test21 {
+
+// Test that we get vbase offsets right in secondary vtables.
+struct A {
+ virtual void f();
+};
+
+struct B : virtual A { };
+class C : virtual B { };
+class D : virtual C { };
+
+class E : virtual C { };
+
+// CHECK: Vtable for 'Test21::F' (16 entries).
+// CHECK-NEXT: 0 | vbase_offset (8)
+// CHECK-NEXT: 1 | vbase_offset (0)
+// CHECK-NEXT: 2 | vbase_offset (0)
+// CHECK-NEXT: 3 | vbase_offset (0)
+// CHECK-NEXT: 4 | vbase_offset (0)
+// CHECK-NEXT: 5 | vcall_offset (0)
+// CHECK-NEXT: 6 | offset_to_top (0)
+// CHECK-NEXT: 7 | Test21::F RTTI
+// CHECK-NEXT: -- (Test21::A, 0) vtable address --
+// CHECK-NEXT: -- (Test21::B, 0) vtable address --
+// CHECK-NEXT: -- (Test21::C, 0) vtable address --
+// CHECK-NEXT: -- (Test21::D, 0) vtable address --
+// CHECK-NEXT: -- (Test21::F, 0) vtable address --
+// CHECK-NEXT: 8 | void Test21::F::f()
+// CHECK-NEXT: 9 | vbase_offset (-8)
+// CHECK-NEXT: 10 | vbase_offset (-8)
+// CHECK-NEXT: 11 | vbase_offset (-8)
+// CHECK-NEXT: 12 | vcall_offset (-8)
+// CHECK-NEXT: 13 | offset_to_top (-8)
+// CHECK-NEXT: 14 | Test21::F RTTI
+// CHECK-NEXT: -- (Test21::A, 8) vtable address --
+// CHECK-NEXT: -- (Test21::B, 8) vtable address --
+// CHECK-NEXT: -- (Test21::C, 8) vtable address --
+// CHECK-NEXT: -- (Test21::E, 8) vtable address --
+// CHECK-NEXT: 15 | [unused] void Test21::F::f()
+class F : virtual D, virtual E {
+ virtual void f();
+};
+void F::f() { }
+
+}