- if (!stmt->base.reachable && fors->initialisation != NULL) {
- warningf(&fors->initialisation->base.source_position,
- "initialisation of for-statement is unreachable");
- }
+ // if init and step are unreachable, cond is unreachable, too
+ if (!stmt->base.reachable && !fors->step_reachable) {
+ warningf(&stmt->base.source_position, "statement is unreachable");
+ } else {
+ if (!stmt->base.reachable && fors->initialisation != NULL) {
+ warningf(&fors->initialisation->base.source_position,
+ "initialisation of for-statement is unreachable");
+ }