QmlJS checks: Don't warn for fallthrough on the last clause.

Change-Id: Ica84ced241eafd82cededa65d2e90f855e448f89
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
Christian Kamm
2011-11-29 10:19:04 +01:00
parent 25842cb13a
commit d02b647bbf
2 changed files with 5 additions and 6 deletions

View File

@@ -1096,12 +1096,9 @@ bool Check::visit(CaseBlock *ast)
for (CaseClauses *it = ast->moreClauses; it; it = it->next) for (CaseClauses *it = ast->moreClauses; it; it = it->next)
clauses += qMakePair(it->clause->caseToken, it->clause->statements); clauses += qMakePair(it->clause->caseToken, it->clause->statements);
for (int i = 0; i < clauses.size(); ++i) { // check all but the last clause for fallthrough
SourceLocation nextToken; for (int i = 0; i < clauses.size() - 1; ++i) {
if (i + 1 < clauses.size()) const SourceLocation nextToken = clauses[i + 1].first;
nextToken = clauses[i + 1].first;
else
nextToken = ast->rbraceToken;
checkCaseFallthrough(clauses[i].second, clauses[i].first, nextToken); checkCaseFallthrough(clauses[i].second, clauses[i].first, nextToken);
} }
return true; return true;

View File

@@ -37,6 +37,8 @@ Item {
case 8: // 20 9 12 case 8: // 20 9 12
x = 1 x = 1
case 9: case 9:
case 11: // no warning
x = 1
} }
} }
} }