diff options
author | Anders Carlsson <andersca@mac.com> | 2009-11-15 16:43:15 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-11-15 16:43:15 +0000 |
commit | 50724302e24d44a27e3bc45e7185a710d6eb3c2d (patch) | |
tree | d2b649dbc11eebe172d0937226db6593f52526aa /lib/Sema | |
parent | 84423a8c8450a1f3ce82730fb35d5ee4e7980701 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88851 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 3e07f3495e..f5ce44e106 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/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<CXXRecordDecl>(Pointee->getAs<RecordType>()->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, |