]> granicus.if.org Git - clang/commitdiff
Disallow function template partial specializations, from Hans
authorDouglas Gregor <dgregor@apple.com>
Mon, 24 Jan 2011 18:54:39 +0000 (18:54 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 24 Jan 2011 18:54:39 +0000 (18:54 +0000)
Wennborg! Fixes PR8295.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124135 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDecl.cpp
test/SemaTemplate/function-template-specialization.cpp

index ce1359df22a34a1b0701a042ced162e46b9f9fc6..0d26ac181621d9322d2371a391d81b26cfaa1fad 100644 (file)
@@ -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<
index 4d8179738a0eb4a492a49901b47df9dc3aae06b6..39d198be392139f363793c9b81d40320d8e399ff 100644 (file)
@@ -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()) {
index 9afc99fe7d5e8a42ecbfcf179f7348607f2294f8..a0d41b2053443faa113254acee32387d1f232821 100644 (file)
@@ -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}}
+}