From b23533db139e0398a8db884c6e2c1f7d4bf7c720 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Tue, 2 Aug 2011 18:05:30 +0000 Subject: [PATCH] PR10566: Make sure codegen for deleting an pointer to an incomplete type actually works. llvm-svn: 136703 --- clang/lib/CodeGen/CGExprCXX.cpp | 2 +- clang/test/CodeGenCXX/delete.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index 7967c822b362..738aac2595e1 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/lib/CodeGen/CGExprCXX.cpp @@ -1206,7 +1206,7 @@ static void EmitObjectDelete(CodeGenFunction &CGF, const CXXDestructorDecl *Dtor = 0; if (const RecordType *RT = ElementType->getAs()) { CXXRecordDecl *RD = cast(RT->getDecl()); - if (!RD->hasTrivialDestructor()) { + if (RD->hasDefinition() && !RD->hasTrivialDestructor()) { Dtor = RD->getDestructor(); if (Dtor->isVirtual()) { diff --git a/clang/test/CodeGenCXX/delete.cpp b/clang/test/CodeGenCXX/delete.cpp index dbef6a0ebcd8..8ad76f8532b4 100644 --- a/clang/test/CodeGenCXX/delete.cpp +++ b/clang/test/CodeGenCXX/delete.cpp @@ -125,9 +125,11 @@ namespace test4 { namespace test5 { struct Incomplete; - // CHECK: define void @_ZN5test523array_delete_incompleteEPNS_10IncompleteE - void array_delete_incomplete(Incomplete *p) { + // CHECK: define void @_ZN5test523array_delete_incompleteEPNS_10IncompleteES1_ + void array_delete_incomplete(Incomplete *p1, Incomplete *p2) { + // CHECK: call void @_ZdlPv + delete p1; // CHECK: call void @_ZdaPv - delete [] p; + delete [] p2; } }