From eac813909b3ca1142ad186f6c6a1b1ae0dbf9378 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Wed, 9 Dec 2009 07:39:44 +0000 Subject: [PATCH] Look through using declarations when searching for allocation overloads. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90961 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExprCXX.cpp | 3 ++- test/SemaCXX/new-delete.cpp | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index f52f4c90c3..16c5275d7d 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -601,7 +601,8 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, Alloc != AllocEnd; ++Alloc) { // Even member operator new/delete are implicitly treated as // static, so don't use AddMemberCandidate. - if (FunctionDecl *Fn = dyn_cast(*Alloc)) { + if (FunctionDecl *Fn = + dyn_cast((*Alloc)->getUnderlyingDecl())) { AddOverloadCandidate(Fn, Args, NumArgs, Candidates, /*SuppressUserConversions=*/false); continue; diff --git a/test/SemaCXX/new-delete.cpp b/test/SemaCXX/new-delete.cpp index f2fe0a78e3..dd28413855 100644 --- a/test/SemaCXX/new-delete.cpp +++ b/test/SemaCXX/new-delete.cpp @@ -202,3 +202,17 @@ struct X11 : X10 { // expected-error {{no suitable member 'operator delete' in ' void f() { X11 x11; // expected-note {{implicit default destructor for 'struct X11' first required here}} } + +struct X12 { + void* operator new(size_t, void*); +}; + +struct X13 : X12 { + using X12::operator new; +}; + +static void* f(void* g) +{ + return new (g) X13(); +} + -- 2.40.0