diff options
author | Chris Lattner <sabre@nondot.org> | 2009-01-04 23:23:14 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-01-04 23:23:14 +0000 |
commit | a7bc7c880f86bc180684ef032d06df51bcae7a23 (patch) | |
tree | 4f12a3f17beda17b06035f9aa4b90c31816b2443 /lib/Parse/ParseExpr.cpp | |
parent | 74ba410e4df194f99021e4d2dda494c853444482 (diff) |
my previous patch caused sema to drop the global qualifier, make
sure to pass it down. This makes the code a bit gross, I will clean
it up in subsequent commits.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61650 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExpr.cpp')
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index c1f6946529..c5ed745d82 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -478,12 +478,14 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression) { // constant: enumeration-constant // Turn a potentially qualified name into a annot_qualtypename or // annot_cxxscope if it would be valid. This handles things like x::y, etc. - TryAnnotateTypeOrScopeToken(); + if (getLang().CPlusPlus) { + TryAnnotateTypeOrScopeToken(); - // If TryAnnotateTypeOrScopeToken modified the current token, then tail - // recurse. - if (Tok.getKind() != tok::identifier) - return ParseCastExpression(isUnaryExpression); + // If TryAnnotateTypeOrScopeToken modified the current token, then tail + // recurse. + if (Tok.getKind() != tok::identifier) + return ParseCastExpression(isUnaryExpression); + } // Consume the identifier so that we can see if it is followed by a '('. // Function designators are allowed to be undeclared (C99 6.5.1p2), so we @@ -630,23 +632,22 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression) { // ::new -> [C++] new-expression // ::delete -> [C++] delete-expression // ::foo::bar -> global qualified name etc. - SourceLocation ScopeLoc = ConsumeToken(); + Token ColonColonTok = Tok; + ConsumeToken(); if (Tok.is(tok::kw_new)) - return ParseCXXNewExpression(true, ScopeLoc); + return ParseCXXNewExpression(true, ColonColonTok.getLocation()); if (Tok.is(tok::kw_delete)) - return ParseCXXDeleteExpression(true, ScopeLoc); + return ParseCXXDeleteExpression(true, ColonColonTok.getLocation()); // Turn the qualified name into a annot_qualtypename or annot_cxxscope if // it would be valid. - TryAnnotateTypeOrScopeToken(); - - // If we still have a :: as our current token, then this is not a type - // name or scope specifier. - if (Tok.getKind() == tok::coloncolon) { - Diag(Tok, diag::err_expected_expression); - return ExprError(); + if (TryAnnotateTypeOrScopeToken(&ColonColonTok)) { + // If so, retry (tail recurse). + return ParseCastExpression(isUnaryExpression); } - // Otherwise, retry (tail recurse). - return ParseCastExpression(isUnaryExpression); + + // This is not a type name or scope specifier, it is an invalid expression. + Diag(ColonColonTok, diag::err_expected_expression); + return ExprError(); } case tok::kw_new: // [C++] new-expression |