diff options
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 10 | ||||
-rw-r--r-- | test/SemaTemplate/member-function-template.cpp | 11 |
2 files changed, 20 insertions, 1 deletions
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<FunctionTemplateDecl>(*Oper)) { + AddMethodTemplateCandidate(FunTmpl, false, 0, 0, Object, Args, NumArgs, + CandidateSet, + /*SuppressUserConversions=*/false); + continue; + } + AddMethodCandidate(cast<CXXMethodDecl>(*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 <class x> x a(x z) { return z+y; } int y; }; +// PR5419 +struct Functor { + template <typename T> + bool operator()(const T& v) const { + return true; + } +}; + +void test_Functor(Functor f) { + f(1); +} |