diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-07-13 00:54:47 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-07-13 00:54:47 +0000 |
commit | a8b20f70d562cdc2679f82d409832b79fc415277 (patch) | |
tree | b46595c0fbeb7c5bb3b707d6f636ab9051e09d82 /test/CodeGenCXX/delete.cpp | |
parent | 9f8ee2ea0a62551ad5488669cf69308e7b48a9dd (diff) |
When compiling ::delete for a class with a virtual destructor, call
the complete destructor and then invoke the global delete
operator. Previously, we would invoke the deleting destructor, which
calls the wrong delete operator. Fixes PR10341.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135021 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/delete.cpp')
-rw-r--r-- | test/CodeGenCXX/delete.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/CodeGenCXX/delete.cpp b/test/CodeGenCXX/delete.cpp index 51c860e909..f3586d4674 100644 --- a/test/CodeGenCXX/delete.cpp +++ b/test/CodeGenCXX/delete.cpp @@ -112,3 +112,22 @@ namespace test3 { delete a; } } + +namespace test4 { + // PR10341: ::delete with a virtual destructor + struct X { + virtual ~X(); + void operator delete (void *); + }; + + // CHECK: define void @_ZN5test421global_delete_virtualEPNS_1XE + void global_delete_virtual(X *xp) { + // CHECK: [[VTABLE:%.*]] = load void ([[X:%.*]])*** + // CHECK-NEXT: [[VFN:%.*]] = getelementptr inbounds void ([[X]])** [[VTABLE]], i64 0 + // CHECK-NEXT: [[VFNPTR:%.*]] = load void ([[X]])** [[VFN]] + // CHECK-NEXT: call void [[VFNPTR]]([[X]] [[OBJ:%.*]]) + // CHECK-NEXT: [[OBJVOID:%.*]] = bitcast [[X]] [[OBJ]] to i8* + // CHECK-NEXT: call void @_ZdlPv(i8* [[OBJVOID]]) nounwind + ::delete xp; + } +} |