diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2009-12-07 15:00:37 +0100 |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2009-12-07 15:01:02 +0100 |
commit | f618a9a2963ac519808385dbd35aeac34e537f67 (patch) | |
tree | b65b169a3983d96dbbd106f86897ff7c5105b744 /src/shared/cplusplus/CheckStatement.cpp | |
parent | 24a4590767cba0da6d372093a7cd777dd021bc88 (diff) | |
download | qt-creator-f618a9a2963ac519808385dbd35aeac34e537f67.tar.gz |
Check for unnecessary semicolons after blocks.
Diffstat (limited to 'src/shared/cplusplus/CheckStatement.cpp')
-rw-r--r-- | src/shared/cplusplus/CheckStatement.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/shared/cplusplus/CheckStatement.cpp b/src/shared/cplusplus/CheckStatement.cpp index ec9f6590e2..b02ba83749 100644 --- a/src/shared/cplusplus/CheckStatement.cpp +++ b/src/shared/cplusplus/CheckStatement.cpp @@ -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; |