Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: add test for reachabil...
details: https://anonhg.NetBSD.org/src/rev/b6dda0f7a495
branches: trunk
changeset: 953840:b6dda0f7a495
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Mar 21 19:39:01 2021 +0000
description:
tests/lint: add test for reachability of non-constant conditions
diffstat:
tests/usr.bin/xlint/lint1/msg_193.c | 41 ++++++++++++++++++++++++++++++----
tests/usr.bin/xlint/lint1/msg_193.exp | 2 +
2 files changed, 38 insertions(+), 5 deletions(-)
diffs (71 lines):
diff -r 58f4847c147e -r b6dda0f7a495 tests/usr.bin/xlint/lint1/msg_193.c
--- a/tests/usr.bin/xlint/lint1/msg_193.c Sun Mar 21 19:18:37 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_193.c Sun Mar 21 19:39:01 2021 +0000
@@ -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 @@
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 */
diff -r 58f4847c147e -r b6dda0f7a495 tests/usr.bin/xlint/lint1/msg_193.exp
--- a/tests/usr.bin/xlint/lint1/msg_193.exp Sun Mar 21 19:18:37 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_193.exp Sun Mar 21 19:39:01 2021 +0000
@@ -80,3 +80,5 @@
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]
Home |
Main Index |
Thread Index |
Old Index