From 2c9e274e57c6d972c1f3ddf5a44778ac6563ffa1 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sun, 15 Nov 2009 16:43:15 +0000 Subject: If we find a deallocation function in the class scope, but it is a placement function we should not look for a deallocation function in the global scope. llvm-svn: 88851 --- clang/lib/Sema/SemaExprCXX.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'clang/lib/Sema/SemaExprCXX.cpp') diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 3e07f3495ee..f5ce44e1063 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -844,12 +844,12 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, DeclarationName DeleteName = Context.DeclarationNames.getCXXOperatorName( ArrayForm ? OO_Array_Delete : OO_Delete); + LookupResult Found; if (Pointee->isRecordType() && !UseGlobal) { CXXRecordDecl *Record = cast(Pointee->getAs()->getDecl()); // Try to find operator delete/operator delete[] in class scope. - LookupResult Found; LookupQualifiedName(Found, Record, DeleteName, LookupOrdinaryName); if (Found.isAmbiguous()) { @@ -867,6 +867,21 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, } } + if (!OperatorDelete && !Found.empty()) { + // We did find operator delete/operator delete[] declarations, but + // none of them were suitable. + Diag(StartLoc, diag::err_no_suitable_delete_member_function_found) + << DeleteName << Record; + + for (LookupResult::iterator F = Found.begin(), FEnd = Found.end(); + F != FEnd; ++F) { + Diag((*F)->getLocation(), + diag::note_delete_member_function_declared_here) + << DeleteName; + } + return ExprError(); + } + if (!Record->hasTrivialDestructor()) if (const CXXDestructorDecl *Dtor = Record->getDestructor(Context)) MarkDeclarationReferenced(StartLoc, -- cgit v1.2.3