diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-01-24 18:54:39 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-01-24 18:54:39 +0000 |
commit | 5505c72695161e2fb55391d1453b82b7adbff923 (patch) | |
tree | ab6a98976e28448e5a52e5b53ca79a559dad0b64 | |
parent | fbcfeeabed6aa60ba664be302f2b03bed3d1b24d (diff) |
Disallow function template partial specializations, from Hans
Wennborg! Fixes PR8295.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124135 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 6 | ||||
-rw-r--r-- | test/SemaTemplate/function-template-specialization.cpp | 5 |
3 files changed, 11 insertions, 2 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index ce1359df22..0d26ac1816 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/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/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 4d8179738a..39d198be39 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/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/test/SemaTemplate/function-template-specialization.cpp b/test/SemaTemplate/function-template-specialization.cpp index 9afc99fe7d..a0d41b2053 100644 --- a/test/SemaTemplate/function-template-specialization.cpp +++ b/test/SemaTemplate/function-template-specialization.cpp @@ -41,3 +41,8 @@ namespace PR5833 { } template <> bool PR5833::f0<float>(float &t1) {} +// PR8295 +namespace PR8295 { + template <typename T> void f(T t) {} + template <typename T> void f<T*>(T* t) {} // expected-error{{function template partial specialization is not allowed}} +} |