Skip to content
Snippets Groups Projects
Commit f618a9a2 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Check for unnecessary semicolons after blocks.

parent 24a45907
No related branches found
No related tags found
No related merge requests found
......@@ -107,8 +107,19 @@ bool CheckStatement::visit(CompoundStatementAST *ast)
ast->symbol = block;
_scope->enterSymbol(block);
Scope *previousScope = switchScope(block->members());
StatementAST *previousStatement = 0;
for (StatementListAST *it = ast->statement_list; it; it = it->next) {
semantic()->check(it->value, _scope);
StatementAST *statement = it->value;
semantic()->check(statement, _scope);
if (statement && previousStatement) {
ExpressionStatementAST *expressionStatement = statement->asExpressionStatement();
CompoundStatementAST *compoundStatement = previousStatement->asCompoundStatement();
if (expressionStatement && ! expressionStatement->expression && compoundStatement && compoundStatement->rbrace_token)
translationUnit()->warning(compoundStatement->rbrace_token, "unnecessary semicolon after block");
}
previousStatement = statement;
}
(void) switchScope(previousScope);
return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment