forked from qt-creator/qt-creator
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:
@@ -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;
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user