Fix a bug/missing-feature Ted noticed: the 'unused' warning should not
warn about the last stmt in a stmtexpr, f.e. there should be no warning for:
int maxval_stmt_expr(int x, int y) {
return ({int _a = x, _b = y; _a > _b ? _a : _b; });
}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41655 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Parse/ParseStmt.cpp b/Parse/ParseStmt.cpp
index 80f7f03..44caaf8 100644
--- a/Parse/ParseStmt.cpp
+++ b/Parse/ParseStmt.cpp
@@ -366,7 +366,7 @@
/// [OMP] barrier-directive
/// [OMP] flush-directive
///
-Parser::StmtResult Parser::ParseCompoundStatement() {
+Parser::StmtResult Parser::ParseCompoundStatement(bool isStmtExpr) {
assert(Tok.getKind() == tok::l_brace && "Not a compount stmt!");
// Enter a scope to hold everything within the compound stmt. Compound
@@ -374,7 +374,7 @@
EnterScope(Scope::DeclScope);
// Parse the statements in the body.
- StmtResult Body = ParseCompoundStatementBody();
+ StmtResult Body = ParseCompoundStatementBody(isStmtExpr);
ExitScope();
return Body;
@@ -385,7 +385,7 @@
/// ParseCompoundStmt action. This expects the '{' to be the current token, and
/// consume the '}' at the end of the block. It does not manipulate the scope
/// stack.
-Parser::StmtResult Parser::ParseCompoundStatementBody() {
+Parser::StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
SourceLocation LBraceLoc = ConsumeBrace(); // eat the '{'.
// TODO: "__label__ X, Y, Z;" is the GNU "Local Label" extension. These are
@@ -442,7 +442,7 @@
SourceLocation RBraceLoc = ConsumeBrace();
return Actions.ParseCompoundStmt(LBraceLoc, RBraceLoc,
- &Stmts[0], Stmts.size());
+ &Stmts[0], Stmts.size(), isStmtExpr);
}
/// ParseIfStatement