[cfe-commits] r49266 - /cfe/trunk/lib/Parse/ParseExprCXX.cpp
Chris Lattner
sabre at nondot.org
Sat Apr 5 23:02:23 PDT 2008
Author: lattner
Date: Sun Apr 6 01:02:23 2008
New Revision: 49266
URL: http://llvm.org/viewvc/llvm-project?rev=49266&view=rev
Log:
finish up throw parsing.
Modified:
cfe/trunk/lib/Parse/ParseExprCXX.cpp
Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=49266&r1=49265&r2=49266&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Sun Apr 6 01:02:23 2008
@@ -87,13 +87,21 @@
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);
+ }
}
More information about the cfe-commits
mailing list