C++: accept loops with arbitrary labels or cases

This commit is contained in:
Robert Marsh
2018-10-22 09:59:49 -07:00
parent b40219bb01
commit 7bcc4379fc
2 changed files with 34 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ where b.getStmt(i) = js
and not s instanceof SwitchCase
// the next statement isn't breaking out of a switch
and not s.(BreakStmt).getBreakable() instanceof SwitchStmt
// the jump isn't a goto into the body of the next statement
and not exists (LabelStmt ls | s.(Loop).getStmt().getAChild*() = ls | ls.getName() = js.(GotoStmt).getName())
// the next statement isn't a loop that can be jumped into
and not exists (LabelStmt ls | s.(Loop).getStmt().getAChild*() = ls)
and not exists (SwitchCase sc | s.(Loop).getStmt().getAChild*() = sc)
select js, "This statement makes $@ unreachable.", s, s.toString()