summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseTemplate.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-11-10 02:40:36 +0000
committerJohn McCall <rjmccall@apple.com>2010-11-10 02:40:36 +0000
commit9b72f89f0fade44dc431fdb9557523439f98ae11 (patch)
treec1c0760cdd280859cddd41d2bdf96d508fc9104c /clang/lib/Parse/ParseTemplate.cpp
parenta4ceea8cd86c4fc649c7c79499ae9dddb9ea20e0 (diff)
downloadbcm5719-llvm-9b72f89f0fade44dc431fdb9557523439f98ae11.tar.gz
bcm5719-llvm-9b72f89f0fade44dc431fdb9557523439f98ae11.zip
Diagnose attempst to template using declarations and using directives.
Recover from the latter and fail early for the former. Fixes PR8022. llvm-svn: 118669
Diffstat (limited to 'clang/lib/Parse/ParseTemplate.cpp')
-rw-r--r--clang/lib/Parse/ParseTemplate.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/clang/lib/Parse/ParseTemplate.cpp b/clang/lib/Parse/ParseTemplate.cpp
index c472972e5cb..333d72a754c 100644
--- a/clang/lib/Parse/ParseTemplate.cpp
+++ b/clang/lib/Parse/ParseTemplate.cpp
@@ -196,12 +196,20 @@ Parser::ParseSingleDeclarationAfterTemplate(
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 @@ Decl *Parser::ParseExplicitInstantiation(SourceLocation ExternLoc,
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;
+}
OpenPOWER on IntegriCloud