From ea0a0a9b3f9a8cd518fb698e2a70a78dbfdffe33 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 11 Jan 2010 18:40:55 +0000 Subject: Implement name lookup for conversion function template specializations (C++ [temp.mem]p5-6), which involves template argument deduction based on the type named, e.g., given struct X { template operator T*(); } x; when we call x.operator int*(); we perform template argument deduction to determine that T=int. This template argument deduction is needed for template specialization and explicit instantiation, e.g., template<> X::operator float*() { /* ... */ } and when calling or otherwise naming a conversion function (as in the first example). This fixes PR5742 and PR5762, although there's some remaining ugliness that's causing out-of-line definitions of conversion function templates to fail. I'll look into that separately. llvm-svn: 93162 --- clang/lib/Sema/SemaTemplate.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'clang/lib/Sema/SemaTemplate.cpp') diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index ecb89edcf7d..5ca8bfde80f 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -4540,8 +4540,10 @@ Sema::DeclResult Sema::ActOnExplicitInstantiation(Scope *S, if (CXXMethodDecl *Method = dyn_cast(Prev)) { if (Context.hasSameUnqualifiedType(Method->getType(), R)) { Matches.clear(); + Matches.push_back(Method); - break; + if (Method->getTemplateSpecializationKind() == TSK_Undeclared) + break; } } } @@ -4553,7 +4555,7 @@ Sema::DeclResult Sema::ActOnExplicitInstantiation(Scope *S, TemplateDeductionInfo Info(Context); FunctionDecl *Specialization = 0; if (TemplateDeductionResult TDK - = DeduceTemplateArguments(FunTmpl, + = DeduceTemplateArguments(FunTmpl, (HasExplicitTemplateArgs ? &TemplateArgs : 0), R, Specialization, Info)) { // FIXME: Keep track of almost-matches? -- cgit v1.2.3