diff options
author | Mike Stump <mrs@apple.com> | 2009-05-15 21:47:08 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-05-15 21:47:08 +0000 |
commit | 6ce0c3981eb2f6000e440f7ea9ad8bb0cd148d0a (patch) | |
tree | 05c91c06ca9a31476807db855aa9267f316fc3fa | |
parent | 4a2e2041edc63db687677325e113b39b9d123c40 (diff) |
Fixup parsing for (throw,throw) and __extension__ throw 1.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71897 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 11 | ||||
-rw-r--r-- | test/Parser/cxx-throw.cpp | 16 |
2 files changed, 18 insertions, 9 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index bfbac3ac26..c3a38b1fe2 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -201,10 +201,7 @@ static prec::Level getBinOpPrecedence(tok::TokenKind Kind, /// 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 @@ Parser::ParseExpressionWithLeadingAt(SourceLocation AtLoc) { /// 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__, diff --git a/test/Parser/cxx-throw.cpp b/test/Parser/cxx-throw.cpp new file mode 100644 index 0000000000..968ef469f9 --- /dev/null +++ b/test/Parser/cxx-throw.cpp @@ -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}} +} |