diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index ce1359df22a3..0d26ac181621 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -1683,6 +1683,8 @@ def err_function_template_spec_ambiguous : Error< "arguments to identify a particular function template">; def note_function_template_spec_matched : Note< "function template matches specialization %0">; +def err_function_template_partial_spec : Error< + "function template partial specialization is not allowed">; // C++ Template Instantiation def err_template_recursion_depth_exceeded : Error< diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 4d8179738a0e..39d198be3921 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -3836,8 +3836,10 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, HasExplicitTemplateArgs = true; if (FunctionTemplate) { - // FIXME: Diagnose function template with explicit template - // arguments. + // Function template with explicit template arguments. + Diag(D.getIdentifierLoc(), diag::err_function_template_partial_spec) + << SourceRange(TemplateId->LAngleLoc, TemplateId->RAngleLoc); + HasExplicitTemplateArgs = false; } else if (!isFunctionTemplateSpecialization && !D.getDeclSpec().isFriendSpecified()) { diff --git a/clang/test/SemaTemplate/function-template-specialization.cpp b/clang/test/SemaTemplate/function-template-specialization.cpp index 9afc99fe7d5e..a0d41b205344 100644 --- a/clang/test/SemaTemplate/function-template-specialization.cpp +++ b/clang/test/SemaTemplate/function-template-specialization.cpp @@ -41,3 +41,8 @@ namespace PR5833 { } template <> bool PR5833::f0(float &t1) {} +// PR8295 +namespace PR8295 { + template void f(T t) {} + template void f(T* t) {} // expected-error{{function template partial specialization is not allowed}} +}