diff options
author | John McCall <rjmccall@apple.com> | 2010-11-10 02:40:36 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-11-10 02:40:36 +0000 |
commit | 78b810559d89e996e00684335407443936ce34a1 (patch) | |
tree | 9640f331e67082f04c10f307eb19807881ca2b26 /lib/Parse/ParseTemplate.cpp | |
parent | 1397399de1cff90e0cb3b1d72097d34bd1a11759 (diff) |
Diagnose attempst to template using declarations and using directives.
Recover from the latter and fail early for the former. Fixes PR8022.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118669 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseTemplate.cpp')
-rw-r--r-- | lib/Parse/ParseTemplate.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp index c472972e5c..333d72a754 100644 --- a/lib/Parse/ParseTemplate.cpp +++ b/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; +} |