diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-04-06 06:02:23 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-04-06 06:02:23 +0000 |
| commit | 65dd843cb44b55e460266086c5e5c694a9208979 (patch) | |
| tree | 81dca89752dcbc5afd432fa6709fc7b1fe80d770 /clang/lib/Parse/ParseExprCXX.cpp | |
| parent | c0a1c7d38778f4b4deae459c8316a06ec5b3f878 (diff) | |
| download | bcm5719-llvm-65dd843cb44b55e460266086c5e5c694a9208979.tar.gz bcm5719-llvm-65dd843cb44b55e460266086c5e5c694a9208979.zip | |
finish up throw parsing.
llvm-svn: 49266
Diffstat (limited to 'clang/lib/Parse/ParseExprCXX.cpp')
| -rw-r--r-- | clang/lib/Parse/ParseExprCXX.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index 6b42fb5b089..c98a7f91f8b 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -87,13 +87,21 @@ Parser::ExprResult Parser::ParseThrowExpression() { ExprResult Expr; SourceLocation ThrowLoc = ConsumeToken(); // Eat the throw token. - // FIXME: Anything that isn't an assignment-expression should bail out now. - if (Tok.is(tok::semi) || Tok.is(tok::r_paren) || Tok.is(tok::colon) || - Tok.is(tok::comma)) + // If the current token isn't the start of an assignment-expression, + // then the expression is not present. This handles things like: + // "C ? throw : (void)42", which is crazy but legal. + switch (Tok.getKind()) { // FIXME: move this predicate somewhere common. + case tok::semi: + case tok::r_paren: + case tok::r_square: + case tok::r_brace: + case tok::colon: + case tok::comma: return Actions.ActOnCXXThrow(ThrowLoc); - Expr = ParseAssignmentExpression(); - if (!Expr.isInvalid) - Expr = Actions.ActOnCXXThrow(ThrowLoc, Expr.Val); - return Expr; + default: + Expr = ParseAssignmentExpression(); + if (Expr.isInvalid) return Expr; + return Actions.ActOnCXXThrow(ThrowLoc, Expr.Val); + } } |

