From: Douglas Gregor Date: Sat, 7 Nov 2009 17:23:56 +0000 (+0000) Subject: Cope with calls to operator() templates. Fixes PR5419. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3734c21b603ec8546613557a0e8a9f566f424324;p=clang Cope with calls to operator() templates. Fixes PR5419. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86387 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 19f0885e8e..00a55b9c36 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -5235,9 +5235,17 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object, DeclarationName OpName = Context.DeclarationNames.getCXXOperatorName(OO_Call); DeclContext::lookup_const_iterator Oper, OperEnd; for (llvm::tie(Oper, OperEnd) = Record->getDecl()->lookup(OpName); - Oper != OperEnd; ++Oper) + Oper != OperEnd; ++Oper) { + if (FunctionTemplateDecl *FunTmpl = dyn_cast(*Oper)) { + AddMethodTemplateCandidate(FunTmpl, false, 0, 0, Object, Args, NumArgs, + CandidateSet, + /*SuppressUserConversions=*/false); + continue; + } + AddMethodCandidate(cast(*Oper), Object, Args, NumArgs, CandidateSet, /*SuppressUserConversions=*/false); + } if (RequireCompleteType(LParenLoc, Object->getType(), PartialDiagnostic(diag::err_incomplete_object_call) diff --git a/test/SemaTemplate/member-function-template.cpp b/test/SemaTemplate/member-function-template.cpp index 83bf16c690..756b510e97 100644 --- a/test/SemaTemplate/member-function-template.cpp +++ b/test/SemaTemplate/member-function-template.cpp @@ -49,3 +49,14 @@ void test_X_f0_explicit(X x, int i, long l) { // PR4608 class A { template x a(x z) { return z+y; } int y; }; +// PR5419 +struct Functor { + template + bool operator()(const T& v) const { + return true; + } +}; + +void test_Functor(Functor f) { + f(1); +}