diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index b134f6ea5107..e4fa380c3dbe 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -6521,9 +6521,9 @@ bool Sema::CheckFunctionTemplateSpecialization( // FIXME: It is somewhat wasteful to build TemplateDeductionInfo Info(FailedCandidates.getLocation()); FunctionDecl *Specialization = 0; - if (TemplateDeductionResult TDK - = DeduceTemplateArguments(FunTmpl, ExplicitTemplateArgs, FT, - Specialization, Info)) { + if (TemplateDeductionResult TDK = DeduceTemplateArguments( + cast(FunTmpl->getFirstDecl()), + ExplicitTemplateArgs, FT, Specialization, Info)) { // Template argument deduction failed; record why it failed, so // that we can provide nifty diagnostics. FailedCandidates.addCandidate() diff --git a/clang/test/SemaTemplate/explicit-specialization-member.cpp b/clang/test/SemaTemplate/explicit-specialization-member.cpp index 9ddbc04953d3..07d73894468f 100644 --- a/clang/test/SemaTemplate/explicit-specialization-member.cpp +++ b/clang/test/SemaTemplate/explicit-specialization-member.cpp @@ -28,3 +28,22 @@ namespace PR12331 { }; template<> struct S::U { static const int n = sizeof(int); }; // expected-error {{explicit specialization of 'U' after instantiation}} } + +namespace PR18246 { + template + class Baz { + public: + template void bar(); + }; + + template + template + void Baz::bar() { + } + + // FIXME: Don't suggest the 'template<>' correction here, because this cannot + // be an explicit specialization. + template + void Baz::bar<0>() { // expected-error {{requires 'template<>'}} + } +}