Diagnose attempst to template using declarations and using directives.
Recover from the latter and fail early for the former.  Fixes PR8022.

llvm-svn: 118669
diff --git a/clang/lib/Parse/ParseTemplate.cpp b/clang/lib/Parse/ParseTemplate.cpp
index c472972..333d72a 100644
--- a/clang/lib/Parse/ParseTemplate.cpp
+++ b/clang/lib/Parse/ParseTemplate.cpp
@@ -196,12 +196,20 @@
     return 0;
   }
 
+  CXX0XAttributeList PrefixAttrs;
+  if (getLang().CPlusPlus0x && isCXX0XAttributeSpecifier())
+    PrefixAttrs = ParseCXX0XAttributes();
+
+  if (Tok.is(tok::kw_using))
+    return ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd,
+                                            PrefixAttrs);
+
   // Parse the declaration specifiers, stealing the accumulated
   // diagnostics from the template parameters.
   ParsingDeclSpec DS(DiagsFromTParams);
 
-  if (getLang().CPlusPlus0x && isCXX0XAttributeSpecifier())
-    DS.AddAttributes(ParseCXX0XAttributes().AttrList);
+  if (PrefixAttrs.HasAttr)
+    DS.AddAttributes(PrefixAttrs.AttrList);
 
   ParseDeclarationSpecifiers(DS, TemplateInfo, AS,
                              getDeclSpecContextFromDeclaratorContext(Context));
@@ -1075,3 +1083,14 @@
                                              ParsingTemplateParams,
                                              DeclEnd, AS_none);
 }
+
+SourceRange Parser::ParsedTemplateInfo::getSourceRange() const {
+  if (TemplateParams)
+    return getTemplateParamsRange(TemplateParams->data(),
+                                  TemplateParams->size());
+
+  SourceRange R(TemplateLoc);
+  if (ExternLoc.isValid())
+    R.setBegin(ExternLoc);
+  return R;
+}