aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGenCXX/vtable-layout.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2010-04-17 17:24:33 +0000
committerAnders Carlsson <andersca@mac.com>2010-04-17 17:24:33 +0000
commitfbf05613db16a521ce124391388891c488c47a0c (patch)
tree3ada79cd53c7f4a871cb33095c5f13ebeb22949e /test/CodeGenCXX/vtable-layout.cpp
parentf6cde77d7bc34bbee26b086ff192637af8e9da59 (diff)
Fix a bug where we would sometimes incorrectly mark an vtable function as unused.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101643 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/vtable-layout.cpp')
-rw-r--r--test/CodeGenCXX/vtable-layout.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/CodeGenCXX/vtable-layout.cpp b/test/CodeGenCXX/vtable-layout.cpp
index 692e8deef3..f2f5179d4a 100644
--- a/test/CodeGenCXX/vtable-layout.cpp
+++ b/test/CodeGenCXX/vtable-layout.cpp
@@ -1598,3 +1598,42 @@ struct H : F, G {
void H::h() { }
}
+
+namespace Test36 {
+
+// Test that we don't mark B::f as unused in the vtable for D.
+
+struct A {
+ virtual void f();
+};
+
+struct B : virtual A { };
+
+struct C : virtual A {
+ virtual void f();
+};
+
+// CHECK: Vtable for 'Test36::D' (12 entries).
+// CHECK-NEXT: 0 | vbase_offset (8)
+// CHECK-NEXT: 1 | vbase_offset (8)
+// CHECK-NEXT: 2 | vcall_offset (0)
+// CHECK-NEXT: 3 | offset_to_top (0)
+// CHECK-NEXT: 4 | Test36::D RTTI
+// CHECK-NEXT: -- (Test36::C, 0) vtable address --
+// CHECK-NEXT: -- (Test36::D, 0) vtable address --
+// CHECK-NEXT: 5 | void Test36::C::f()
+// CHECK-NEXT: 6 | void Test36::D::g()
+// CHECK-NEXT: 7 | vbase_offset (0)
+// CHECK-NEXT: 8 | vcall_offset (-8)
+// CHECK-NEXT: 9 | offset_to_top (-8)
+// CHECK-NEXT: 10 | Test36::D RTTI
+// CHECK-NEXT: -- (Test36::A, 8) vtable address --
+// CHECK-NEXT: -- (Test36::B, 8) vtable address --
+// CHECK-NEXT: 11 | void Test36::C::f()
+// CHECK-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
+struct D : virtual B, C {
+ virtual void g();
+};
+void D::g() { }
+
+}