[cfe-commits] r71897 - in /cfe/trunk: lib/Parse/ParseExpr.cpp test/Parser/cxx-throw.cpp
Mike Stump
mrs at apple.com
Fri May 15 14:47:08 PDT 2009
Author: mrs
Date: Fri May 15 16:47:08 2009
New Revision: 71897
URL: http://llvm.org/viewvc/llvm-project?rev=71897&view=rev
Log:
Fixup parsing for (throw,throw) and __extension__ throw 1.
Added:
cfe/trunk/test/Parser/cxx-throw.cpp
Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=71897&r1=71896&r2=71897&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Fri May 15 16:47:08 2009
@@ -201,10 +201,7 @@
/// 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);
@@ -228,11 +225,7 @@
/// 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__,
Added: cfe/trunk/test/Parser/cxx-throw.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-throw.cpp?rev=71897&view=auto
==============================================================================
--- cfe/trunk/test/Parser/cxx-throw.cpp (added)
+++ cfe/trunk/test/Parser/cxx-throw.cpp Fri May 15 16:47:08 2009
@@ -0,0 +1,16 @@
+// 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}}
+}
More information about the cfe-commits
mailing list