summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseDeclCXX.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-05-09 08:23:23 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-05-09 08:23:23 +0000
commit45855df4c67960da662e8777ff520f2f0f07c5bd (patch)
treef9b4461935be0916dca5a75af1a35660cd6bc352 /clang/lib/Parse/ParseDeclCXX.cpp
parent28540adfcf0ec6eab41c812dfae337199f7fa641 (diff)
downloadbcm5719-llvm-45855df4c67960da662e8777ff520f2f0f07c5bd.tar.gz
bcm5719-llvm-45855df4c67960da662e8777ff520f2f0f07c5bd.zip
Recover properly if a class member declaration starts with a scope specifier
or template-id which can't be parsed. llvm-svn: 156468
Diffstat (limited to 'clang/lib/Parse/ParseDeclCXX.cpp')
-rw-r--r--clang/lib/Parse/ParseDeclCXX.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 730c345d807..e7d4ac7c37b 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -1704,12 +1704,16 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
}
// Access declarations.
+ bool MalformedTypeSpec = false;
if (!TemplateInfo.Kind &&
- (Tok.is(tok::identifier) || Tok.is(tok::coloncolon)) &&
- !TryAnnotateCXXScopeToken() &&
- Tok.is(tok::annot_cxxscope)) {
- bool isAccessDecl = false;
- if (NextToken().is(tok::identifier))
+ (Tok.is(tok::identifier) || Tok.is(tok::coloncolon))) {
+ if (TryAnnotateCXXScopeToken())
+ MalformedTypeSpec = true;
+
+ bool isAccessDecl;
+ if (Tok.isNot(tok::annot_cxxscope))
+ isAccessDecl = false;
+ else if (NextToken().is(tok::identifier))
isAccessDecl = GetLookAheadToken(2).is(tok::semi);
else
isAccessDecl = NextToken().is(tok::kw_operator);
@@ -1806,6 +1810,8 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
// Parse the common declaration-specifiers piece.
ParsingDeclSpec DS(*this, TemplateDiags);
DS.takeAttributesFrom(attrs);
+ if (MalformedTypeSpec)
+ DS.SetTypeSpecError();
ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DSC_class,
&CommonLateParsedAttrs);
OpenPOWER on IntegriCloud