[cfe-commits] r86387 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaTemplate/member-function-template.cpp
Douglas Gregor
dgregor at apple.com
Sat Nov 7 09:23:56 PST 2009
Author: dgregor
Date: Sat Nov 7 11:23:56 2009
New Revision: 86387
URL: http://llvm.org/viewvc/llvm-project?rev=86387&view=rev
Log:
Cope with calls to operator() templates. Fixes PR5419.
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaTemplate/member-function-template.cpp
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=86387&r1=86386&r2=86387&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Sat Nov 7 11:23:56 2009
@@ -5235,9 +5235,17 @@
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)
Modified: cfe/trunk/test/SemaTemplate/member-function-template.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/member-function-template.cpp?rev=86387&r1=86386&r2=86387&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/member-function-template.cpp (original)
+++ cfe/trunk/test/SemaTemplate/member-function-template.cpp Sat Nov 7 11:23:56 2009
@@ -49,3 +49,14 @@
// 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);
+}
More information about the cfe-commits
mailing list