diff options
author | John McCall <rjmccall@apple.com> | 2009-12-19 00:35:18 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2009-12-19 00:35:18 +0000 |
commit | ae03cb5a84d13c7a0d4b21865bd63aabd18120d2 (patch) | |
tree | df8b6f36fe5b797911bc53c870c50f4bddda6a9c /lib/Parse/Parser.cpp | |
parent | 27a9b72bf1e4fe9f1d3ee9a5db1b9d614b0ee01c (diff) |
Teach TryAnnotateTypeOrScopeToken to deal with already-annotated
scope specifiers. Fix a tentative parsing bug that came up in LLVM.
Incidentally fixes some random FIXMEs in an existing testcase.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91734 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/Parser.cpp')
-rw-r--r-- | lib/Parse/Parser.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index a864e7c24c..52c0153bfa 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -880,7 +880,7 @@ Parser::OwningExprResult Parser::ParseSimpleAsm(SourceLocation *EndLoc) { /// as the current tokens, so only call it in contexts where these are invalid. bool Parser::TryAnnotateTypeOrScopeToken(bool EnteringContext) { assert((Tok.is(tok::identifier) || Tok.is(tok::coloncolon) - || Tok.is(tok::kw_typename)) && + || Tok.is(tok::kw_typename) || Tok.is(tok::annot_cxxscope)) && "Cannot be a type or scope token!"); if (Tok.is(tok::kw_typename)) { @@ -935,6 +935,9 @@ bool Parser::TryAnnotateTypeOrScopeToken(bool EnteringContext) { return true; } + // Remembers whether the token was originally a scope annotation. + bool wasScopeAnnotation = Tok.is(tok::annot_cxxscope); + CXXScopeSpec SS; if (getLang().CPlusPlus) ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, EnteringContext); @@ -1017,9 +1020,11 @@ bool Parser::TryAnnotateTypeOrScopeToken(bool EnteringContext) { Tok.setAnnotationValue(SS.getScopeRep()); Tok.setAnnotationRange(SS.getRange()); - // In case the tokens were cached, have Preprocessor replace them with the - // annotation token. - PP.AnnotateCachedTokens(Tok); + // In case the tokens were cached, have Preprocessor replace them + // with the annotation token. We don't need to do this if we've + // just reverted back to the state we were in before being called. + if (!wasScopeAnnotation) + PP.AnnotateCachedTokens(Tok); return true; } |