summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseExpr.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-04-06 02:35:25 +0000
committerJohn McCall <rjmccall@apple.com>2011-04-06 02:35:25 +0000
commitc5e6b975230e3bdc4181783cb6cb7f4dc22176ba (patch)
treecc8fc5e1dae4f940401df6b056fff2777258a278 /clang/lib/Parse/ParseExpr.cpp
parent75ca6d72c2964bc931715510dad99f587584f583 (diff)
downloadbcm5719-llvm-c5e6b975230e3bdc4181783cb6cb7f4dc22176ba.tar.gz
bcm5719-llvm-c5e6b975230e3bdc4181783cb6cb7f4dc22176ba.zip
Diagnose a missing ')' on what looks like a statement expression.
A situation where we can get an invalid ExprResult without an error. Fixes PR8394. Patch by Justin Bogner! llvm-svn: 128979
Diffstat (limited to 'clang/lib/Parse/ParseExpr.cpp')
-rw-r--r--clang/lib/Parse/ParseExpr.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 510e2c2801a..d8d73e92393 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1631,6 +1631,9 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
ConsumeCodeCompletionToken();
return ExprError();
}
+
+ // None of these cases should fall through with an invalid Result
+ // unless they've already reported an error.
if (ExprType >= CompoundStmt && Tok.is(tok::l_brace)) {
Diag(Tok, diag::ext_gnu_statement_expr);
@@ -1639,7 +1642,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
ExprType = CompoundStmt;
// If the substmt parsed correctly, build the AST node.
- if (!Stmt.isInvalid() && Tok.is(tok::r_paren))
+ if (!Stmt.isInvalid())
Result = Actions.ActOnStmtExpr(OpenLoc, Stmt.take(), Tok.getLocation());
} else if (ExprType >= CompoundLiteral &&
@@ -1737,6 +1740,8 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
Result = ParseExpression();
ExprType = SimpleExpr;
+
+ // Don't build a paren expression unless we actually match a ')'.
if (!Result.isInvalid() && Tok.is(tok::r_paren))
Result = Actions.ActOnParenExpr(OpenLoc, Tok.getLocation(), Result.take());
}
OpenPOWER on IntegriCloud