Added semantic checks for compound expressions.

This commit is contained in:
Erik Verbruggen
2010-02-04 16:31:29 +01:00
parent fd90c3503d
commit 6ca5f5f5f8
8 changed files with 74 additions and 27 deletions

View File

@@ -3446,6 +3446,14 @@ bool Parser::parsePrimaryExpression(ExpressionAST *&node)
ast->compoundStatement = statement->asCompoundStatement();
match(T_RPAREN, &ast->rparen_token);
node = ast;
if (ast->compoundStatement && ast->compoundStatement->statement_list) {
// check that the last statement is an expression-statement
StatementAST *lastStmt = ast->compoundStatement->statement_list->lastValue();
if (!lastStmt || ! ast->asExpressionStatement())
_translationUnit->error(cursor(),
"expected an expression statement before token `%s'",
tok().spell());
}
return true;
} else {
return parseNestedExpression(node);