diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2009-01-27 08:43:38 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2009-01-27 08:43:38 +0000 |
| commit | eb3a9b03ab3379185c8af2574272149a7f9a56c6 (patch) | |
| tree | e88c0d5d260392f66f9937af4f0d8531001a19ba /clang/lib/Parse/ParseExpr.cpp | |
| parent | f1ca7d3e02e0fb4d5fa6ed56459a31776e82a605 (diff) | |
| download | bcm5719-llvm-eb3a9b03ab3379185c8af2574272149a7f9a56c6.tar.gz bcm5719-llvm-eb3a9b03ab3379185c8af2574272149a7f9a56c6.zip | |
Fix for PR3418: make sure to handle the RHS of expressions starting with
__extension__. This sort of construct shows up in the gcc source code.
llvm-svn: 63100
Diffstat (limited to 'clang/lib/Parse/ParseExpr.cpp')
| -rw-r--r-- | clang/lib/Parse/ParseExpr.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 38518557a3f..1bec279890d 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -192,6 +192,25 @@ Parser::ParseExpressionWithLeadingAt(SourceLocation AtLoc) { return ParseRHSOfBinaryExpression(move(LHS), prec::Comma); } +/// This routine is called when a leading '__extension__' is seen and +/// consumed. This is necessary because the token gets consumed in the +/// process of disambiguating between an expression and a declaration. +Parser::OwningExprResult +Parser::ParseExpressionWithLeadingExtension(SourceLocation ExtLoc) { + // FIXME: The handling for throw is almost certainly wrong. + if (Tok.is(tok::kw_throw)) + return ParseThrowExpression(); + + OwningExprResult LHS(ParseCastExpression(false)); + if (LHS.isInvalid()) return move(LHS); + + LHS = Actions.ActOnUnaryOp(CurScope, ExtLoc, tok::kw___extension__, + move_arg(LHS)); + if (LHS.isInvalid()) return move(LHS); + + return ParseRHSOfBinaryExpression(move(LHS), prec::Comma); +} + /// ParseAssignmentExpression - Parse an expr that doesn't include commas. /// Parser::OwningExprResult Parser::ParseAssignmentExpression() { |

