[cfe-commits] r124135 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDecl.cpp test/SemaTemplate/function-template-specialization.cpp

Douglas Gregor dgregor at apple.com
Mon Jan 24 10:54:39 PST 2011


Author: dgregor
Date: Mon Jan 24 12:54:39 2011
New Revision: 124135

URL: http://llvm.org/viewvc/llvm-project?rev=124135&view=rev
Log:
Disallow function template partial specializations, from Hans
Wennborg! Fixes PR8295.

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

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=124135&r1=124134&r2=124135&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Jan 24 12:54:39 2011
@@ -1683,6 +1683,8 @@
     "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<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=124135&r1=124134&r2=124135&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Jan 24 12:54:39 2011
@@ -3836,8 +3836,10 @@
       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()) {

Modified: cfe/trunk/test/SemaTemplate/function-template-specialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/function-template-specialization.cpp?rev=124135&r1=124134&r2=124135&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/function-template-specialization.cpp (original)
+++ cfe/trunk/test/SemaTemplate/function-template-specialization.cpp Mon Jan 24 12:54:39 2011
@@ -41,3 +41,8 @@
 }
 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}}
+}





More information about the cfe-commits mailing list