]> granicus.if.org Git - clang/commitdiff
Cope with calls to operator() templates. Fixes PR5419.
authorDouglas Gregor <dgregor@apple.com>
Sat, 7 Nov 2009 17:23:56 +0000 (17:23 +0000)
committerDouglas Gregor <dgregor@apple.com>
Sat, 7 Nov 2009 17:23:56 +0000 (17:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86387 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOverload.cpp
test/SemaTemplate/member-function-template.cpp

index 19f0885e8e0a4e2fc27e3b8e122489ad0ff92510..00a55b9c365364517b8f5e6bb3c79e84c6097bc6 100644 (file)
@@ -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)
index 83bf16c69004d6a810b2baaabd3d44fc2e893076..756b510e97fd90bea290cad3b6ee14e8646adb9d 100644 (file)
@@ -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);
+}