diff options
author | John McCall <rjmccall@apple.com> | 2012-04-04 01:27:53 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2012-04-04 01:27:53 +0000 |
commit | 3abee49d1c06f86761944375c112fcf55f59a261 (patch) | |
tree | 3d8291594d37d3f153f0cbd2650ab82d4895e67c /clang/lib/Parse/ParseExpr.cpp | |
parent | 34b4546c06564e6a9d32370e65231494ed1f5abb (diff) | |
download | bcm5719-llvm-3abee49d1c06f86761944375c112fcf55f59a261.tar.gz bcm5719-llvm-3abee49d1c06f86761944375c112fcf55f59a261.zip |
Enter an expression evaluation context when parsing
statement-expressions. Prevents cleanups and such from being
claimed by the first full-expression in the block.
llvm-svn: 153989
Diffstat (limited to 'clang/lib/Parse/ParseExpr.cpp')
-rw-r--r-- | clang/lib/Parse/ParseExpr.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 888e84f2532..752e5c502d4 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -1917,13 +1917,19 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr, // unless they've already reported an error. if (ExprType >= CompoundStmt && Tok.is(tok::l_brace)) { Diag(Tok, diag::ext_gnu_statement_expr); + + Actions.ActOnStartStmtExpr(); + ParsedAttributes attrs(AttrFactory); StmtResult Stmt(ParseCompoundStatement(attrs, true)); ExprType = CompoundStmt; // If the substmt parsed correctly, build the AST node. - if (!Stmt.isInvalid()) + if (!Stmt.isInvalid()) { Result = Actions.ActOnStmtExpr(OpenLoc, Stmt.take(), Tok.getLocation()); + } else { + Actions.ActOnStmtExprError(); + } } else if (ExprType >= CompoundLiteral && BridgeCast) { tok::TokenKind tokenKind = Tok.getKind(); SourceLocation BridgeKeywordLoc = ConsumeToken(); |