Module Name: src
Committed By: rillig
Date: Sun Mar 21 19:39:01 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 non-constant conditions
To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 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.9 src/tests/usr.bin/xlint/lint1/msg_193.c:1.10
--- src/tests/usr.bin/xlint/lint1/msg_193.c:1.9 Sun Mar 21 19:18:37 2021
+++ src/tests/usr.bin/xlint/lint1/msg_193.c Sun Mar 21 19:39:01 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_193.c,v 1.9 2021/03/21 19:18:37 rillig Exp $ */
+/* $NetBSD: msg_193.c,v 1.10 2021/03/21 19:39:01 rillig Exp $ */
# 3 "msg_193.c"
// Test for message: statement not reached [193]
@@ -22,10 +22,10 @@
* system-dependent constant expression
*/
-extern void
-reachable(void);
-extern void
-unreachable(void);
+extern void reachable(void);
+extern void unreachable(void);
+extern _Bool maybe(void);
+
void
test_statement(void)
@@ -524,6 +524,37 @@ test_if_nested(void)
reachable();
}
+void
+test_if_maybe(void)
+{
+ if (maybe()) {
+ if (0)
+ unreachable(); /* expect: 193 */
+ else
+ reachable();
+ reachable();
+ }
+ reachable();
+
+ if (0) {
+ if (maybe()) /* expect: 193 */
+ unreachable();
+ else
+ unreachable();
+ unreachable();
+ }
+ reachable();
+
+ if (1) {
+ if (maybe())
+ reachable();
+ 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.9 src/tests/usr.bin/xlint/lint1/msg_193.exp:1.10
--- src/tests/usr.bin/xlint/lint1/msg_193.exp:1.9 Sun Mar 21 19:18:37 2021
+++ src/tests/usr.bin/xlint/lint1/msg_193.exp Sun Mar 21 19:39:01 2021
@@ -80,3 +80,5 @@ msg_193.c(500): warning: statement not r
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]
+msg_193.c(532): warning: statement not reached [193]
+msg_193.c(540): warning: statement not reached [193]