/// expression ',' assignment-expression
///
Parser::OwningExprResult Parser::ParseExpression() {
- if (Tok.is(tok::kw_throw))
- return ParseThrowExpression();
-
- OwningExprResult LHS(ParseCastExpression(false));
+ OwningExprResult LHS(ParseAssignmentExpression());
if (LHS.isInvalid()) return move(LHS);
return ParseRHSOfBinaryExpression(move(LHS), prec::Comma);
/// 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));
+ OwningExprResult LHS(ParseAssignmentExpression());
if (LHS.isInvalid()) return move(LHS);
LHS = Actions.ActOnUnaryOp(CurScope, ExtLoc, tok::kw___extension__,
--- /dev/null
+// RUN: clang-cc -fsyntax-only -verify %s
+
+int i;
+
+void foo() {
+ (throw,throw);
+ (1 ? throw 1 : throw 2);
+ throw int(1);
+ throw;
+ throw 1;
+ throw;
+ 1 ? throw : (void)42;
+ // gcc doesn't parse the below, but we do
+ __extension__ throw 1;
+ (void)throw; // expected-error {{expected expression}}
+}