Module Name: src Committed By: rillig Date: Sun Mar 21 19:18:37 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: msg_193.c msg_193.exp Log Message: tests/lint: add test for reachability of nested 'if' statements To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/msg_193.c \ src/tests/usr.bin/xlint/lint1/msg_193.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/xlint/lint1/msg_193.c diff -u src/tests/usr.bin/xlint/lint1/msg_193.c:1.8 src/tests/usr.bin/xlint/lint1/msg_193.c:1.9 --- src/tests/usr.bin/xlint/lint1/msg_193.c:1.8 Sun Mar 21 19:14:40 2021 +++ src/tests/usr.bin/xlint/lint1/msg_193.c Sun Mar 21 19:18:37 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_193.c,v 1.8 2021/03/21 19:14:40 rillig Exp $ */ +/* $NetBSD: msg_193.c,v 1.9 2021/03/21 19:18:37 rillig Exp $ */ # 3 "msg_193.c" // Test for message: statement not reached [193] @@ -490,6 +490,40 @@ test_do_while_if_return(void) unreachable(); /* expect: 193 */ } +void +test_if_nested(void) +{ + if (0) { + if (1) /* expect: 193 */ + unreachable(); + else + unreachable(); /* expect: 193 *//* XXX: redundant */ + + if (0) + unreachable(); /* expect: 193 *//* XXX: redundant */ + else + unreachable(); + + unreachable(); + } + reachable(); + + if (1) { + if (1) + reachable(); + else + unreachable(); /* expect: 193 */ + + if (0) + unreachable(); /* expect: 193 */ + else + reachable(); + + reachable(); + } + reachable(); +} + /* TODO: switch */ /* TODO: goto */ Index: src/tests/usr.bin/xlint/lint1/msg_193.exp diff -u src/tests/usr.bin/xlint/lint1/msg_193.exp:1.8 src/tests/usr.bin/xlint/lint1/msg_193.exp:1.9 --- src/tests/usr.bin/xlint/lint1/msg_193.exp:1.8 Sun Mar 21 19:14:40 2021 +++ src/tests/usr.bin/xlint/lint1/msg_193.exp Sun Mar 21 19:18:37 2021 @@ -75,3 +75,8 @@ msg_193.c(481): warning: statement not r msg_193.c(486): warning: statement not reached [193] msg_193.c(488): warning: statement not reached [193] msg_193.c(490): warning: statement not reached [193] +msg_193.c(497): warning: statement not reached [193] +msg_193.c(500): warning: statement not reached [193] +msg_193.c(503): warning: statement not reached [193] +msg_193.c(515): warning: statement not reached [193] +msg_193.c(518): warning: statement not reached [193]