Fix a crash on template delete operators.

llvm-svn: 110542
This commit is contained in:
Chandler Carruth 2010-08-08 07:04:00 +00:00
parent 7f36ac54d7
commit 9b41823177
2 changed files with 20 additions and 2 deletions

View File

@ -1301,8 +1301,14 @@ bool Sema::FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD,
llvm::SmallVector<DeclAccessPair,4> Matches;
for (LookupResult::iterator F = Found.begin(), FEnd = Found.end();
F != FEnd; ++F) {
CXXMethodDecl *Delete = cast<CXXMethodDecl>((*F)->getUnderlyingDecl());
if (Delete->isUsualDeallocationFunction())
NamedDecl *ND = (*F)->getUnderlyingDecl();
// Ignore template operator delete members from the check for a usual
// deallocation function.
if (isa<FunctionTemplateDecl>(ND))
continue;
if (cast<CXXMethodDecl>(ND)->isUsualDeallocationFunction())
Matches.push_back(F.getPair());
}

View File

@ -332,3 +332,15 @@ namespace PR7810 {
static void operator delete(void *volatile);
};
}
// Don't crash on template delete operators
namespace TemplateDestructors {
struct S {
virtual ~S() {}
void* operator new(const size_t size);
template<class T> void* operator new(const size_t, const int, T*);
void operator delete(void*, const size_t);
template<class T> void operator delete(void*, const size_t, const int, T*);
};
}