Support friend function specializations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99389 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index bf92ef8..1435a8f 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -2918,6 +2918,13 @@
     } else {
       // This is a function template specialization.
       isFunctionTemplateSpecialization = true;
+
+      // C++0x [temp.expl.spec]p20 forbids "template<> void foo(int);".
+      if (isFriend && isFunctionTemplateSpecialization) {
+        SourceRange Range = TemplateParams->getSourceRange();
+        Diag(D.getIdentifierLoc(), diag::err_template_spec_decl_friend)
+          << Name << Range << CodeModificationHint::CreateRemoval(Range);
+      }
     }
 
     // FIXME: Free this memory properly.
@@ -3101,6 +3108,9 @@
                                    D.getDeclSpec().getSourceRange().getBegin(),
                                                  "template<> ");
       isFunctionTemplateSpecialization = true;
+    } else {
+      // "friend void foo<>(int);" is an implicit specialization decl.
+      isFunctionTemplateSpecialization = true;
     }
   }