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/e2225d864098
branches:  trunk
changeset: 960586:e2225d864098
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Mar 21 19:18:37 2021 +0000

description:
tests/lint: add test for reachability of nested 'if' statements

diffstat:

 tests/usr.bin/xlint/lint1/msg_193.c   |  36 ++++++++++++++++++++++++++++++++++-
 tests/usr.bin/xlint/lint1/msg_193.exp |   5 ++++
 2 files changed, 40 insertions(+), 1 deletions(-)

diffs (62 lines):

diff -r d0c585629c90 -r e2225d864098 tests/usr.bin/xlint/lint1/msg_193.c
--- a/tests/usr.bin/xlint/lint1/msg_193.c       Sun Mar 21 19:14:40 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_193.c       Sun Mar 21 19:18:37 2021 +0000
@@ -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 @@
        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 */
diff -r d0c585629c90 -r e2225d864098 tests/usr.bin/xlint/lint1/msg_193.exp
--- a/tests/usr.bin/xlint/lint1/msg_193.exp     Sun Mar 21 19:14:40 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_193.exp     Sun Mar 21 19:18:37 2021 +0000
@@ -75,3 +75,8 @@
 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]



Home | Main Index | Thread Index | Old Index