diff --git a/cpp/ql/lib/semmle/code/cpp/stmts/Stmt.qll b/cpp/ql/lib/semmle/code/cpp/stmts/Stmt.qll index c974353bc7a..b7905a9d23f 100644 --- a/cpp/ql/lib/semmle/code/cpp/stmts/Stmt.qll +++ b/cpp/ql/lib/semmle/code/cpp/stmts/Stmt.qll @@ -1516,8 +1516,10 @@ class SwitchCase extends Stmt, @stmt_switch_case { * which has result `default:`, which has no result. */ SwitchCase getNextSwitchCase() { - result.getSwitchStmt() = this.getSwitchStmt() and - result.getChildNum() = this.getChildNum() + 1 + exists(SwitchStmt s, int n | + this = s.getSwitchCase(n) and + result = s.getSwitchCase(n + 1) + ) } /**