Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: warn about unreachable statement a...
details: https://anonhg.NetBSD.org/src/rev/c4eee1504389
branches: trunk
changeset: 953838:c4eee1504389
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Mar 21 19:14:40 2021 +0000
description:
lint: warn about unreachable statement after joining the 'if' branches
diffstat:
tests/usr.bin/xlint/lint1/msg_193.c | 20 ++++++++++----------
tests/usr.bin/xlint/lint1/msg_193.exp | 9 +++++++++
usr.bin/xlint/lint1/func.c | 12 +++---------
3 files changed, 22 insertions(+), 19 deletions(-)
diffs (186 lines):
diff -r 59cf0ff57049 -r c4eee1504389 tests/usr.bin/xlint/lint1/msg_193.c
--- a/tests/usr.bin/xlint/lint1/msg_193.c Sun Mar 21 19:08:10 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_193.c Sun Mar 21 19:14:40 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_193.c,v 1.7 2021/03/21 15:44:57 rillig Exp $ */
+/* $NetBSD: msg_193.c,v 1.8 2021/03/21 19:14:40 rillig Exp $ */
# 3 "msg_193.c"
// Test for message: statement not reached [193]
@@ -203,7 +203,7 @@
break;
unreachable(); /* expect: 193 */
}
- unreachable(); /* TODO: expect: 193 */
+ unreachable(); /* expect: 193 */
}
reachable();
}
@@ -234,7 +234,7 @@
continue;
unreachable(); /* expect: 193 */
}
- unreachable(); /* TODO: expect: 193 */
+ unreachable(); /* expect: 193 */
}
unreachable(); /* expect: 193 */
}
@@ -265,7 +265,7 @@
return;
unreachable(); /* expect: 193 */
}
- unreachable(); /* TODO: expect: 193 */
+ unreachable(); /* expect: 193 */
}
unreachable(); /* expect: 193 */
}
@@ -312,7 +312,7 @@
break;
unreachable(); /* expect: 193 */
}
- unreachable(); /* TODO: expect: 193 */
+ unreachable(); /* expect: 193 */
}
reachable();
}
@@ -343,7 +343,7 @@
continue;
unreachable(); /* expect: 193 */
}
- unreachable(); /* TODO: expect: 193 */
+ unreachable(); /* expect: 193 */
}
unreachable(); /* expect: 193 */
}
@@ -374,7 +374,7 @@
return;
unreachable(); /* expect: 193 */
}
- unreachable(); /* TODO: expect: 193 */
+ unreachable(); /* expect: 193 */
}
unreachable(); /* expect: 193 */
}
@@ -423,7 +423,7 @@
break;
unreachable(); /* expect: 193 */
}
- unreachable(); /* TODO: expect: 193 */
+ unreachable(); /* expect: 193 */
} while (1);
reachable();
}
@@ -454,7 +454,7 @@
continue;
unreachable(); /* expect: 193 */
}
- unreachable(); /* TODO: expect: 193 */
+ unreachable(); /* expect: 193 */
} while (1);
unreachable(); /* expect: 193 */
}
@@ -485,7 +485,7 @@
return;
unreachable(); /* expect: 193 */
}
- unreachable(); /* TODO: expect: 193 */
+ unreachable(); /* expect: 193 */
} while (1);
unreachable(); /* expect: 193 */
}
diff -r 59cf0ff57049 -r c4eee1504389 tests/usr.bin/xlint/lint1/msg_193.exp
--- a/tests/usr.bin/xlint/lint1/msg_193.exp Sun Mar 21 19:08:10 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_193.exp Sun Mar 21 19:14:40 2021 +0000
@@ -19,17 +19,20 @@
msg_193.c(197): warning: statement not reached [193]
msg_193.c(199): warning: statement not reached [193]
msg_193.c(204): warning: statement not reached [193]
+msg_193.c(206): warning: statement not reached [193]
msg_193.c(217): warning: statement not reached [193]
msg_193.c(219): warning: statement not reached [193]
msg_193.c(228): warning: statement not reached [193]
msg_193.c(230): warning: statement not reached [193]
msg_193.c(235): warning: statement not reached [193]
+msg_193.c(237): warning: statement not reached [193]
msg_193.c(239): warning: statement not reached [193]
msg_193.c(248): warning: statement not reached [193]
msg_193.c(250): warning: statement not reached [193]
msg_193.c(259): warning: statement not reached [193]
msg_193.c(261): warning: statement not reached [193]
msg_193.c(266): warning: statement not reached [193]
+msg_193.c(268): warning: statement not reached [193]
msg_193.c(270): warning: statement not reached [193]
msg_193.c(278): warning: statement not reached [193]
msg_193.c(285): warning: statement not reached [193]
@@ -37,32 +40,38 @@
msg_193.c(306): warning: statement not reached [193]
msg_193.c(308): warning: statement not reached [193]
msg_193.c(313): warning: statement not reached [193]
+msg_193.c(315): warning: statement not reached [193]
msg_193.c(326): warning: statement not reached [193]
msg_193.c(328): warning: statement not reached [193]
msg_193.c(337): warning: statement not reached [193]
msg_193.c(339): warning: statement not reached [193]
msg_193.c(344): warning: statement not reached [193]
+msg_193.c(346): warning: statement not reached [193]
msg_193.c(348): warning: statement not reached [193]
msg_193.c(357): warning: statement not reached [193]
msg_193.c(359): warning: statement not reached [193]
msg_193.c(368): warning: statement not reached [193]
msg_193.c(370): warning: statement not reached [193]
msg_193.c(375): warning: statement not reached [193]
+msg_193.c(377): warning: statement not reached [193]
msg_193.c(379): warning: statement not reached [193]
msg_193.c(388): warning: statement not reached [193]
msg_193.c(406): warning: statement not reached [193]
msg_193.c(417): warning: statement not reached [193]
msg_193.c(419): warning: statement not reached [193]
msg_193.c(424): warning: statement not reached [193]
+msg_193.c(426): warning: statement not reached [193]
msg_193.c(437): warning: statement not reached [193]
msg_193.c(439): warning: statement not reached [193]
msg_193.c(448): warning: statement not reached [193]
msg_193.c(450): warning: statement not reached [193]
msg_193.c(455): warning: statement not reached [193]
+msg_193.c(457): warning: statement not reached [193]
msg_193.c(459): warning: statement not reached [193]
msg_193.c(468): warning: statement not reached [193]
msg_193.c(470): warning: statement not reached [193]
msg_193.c(479): warning: statement not reached [193]
msg_193.c(481): warning: statement not reached [193]
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]
diff -r 59cf0ff57049 -r c4eee1504389 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c Sun Mar 21 19:08:10 2021 +0000
+++ b/usr.bin/xlint/lint1/func.c Sun Mar 21 19:14:40 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: func.c,v 1.94 2021/03/21 19:08:10 rillig Exp $ */
+/* $NetBSD: func.c,v 1.95 2021/03/21 19:14:40 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.94 2021/03/21 19:08:10 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.95 2021/03/21 19:14:40 rillig Exp $");
#endif
#include <stdlib.h>
@@ -203,13 +203,7 @@
if (!reached && warn_about_unreachable) {
/* statement not reached */
warning(193);
- /*
- * FIXME: Setting 'reached = true' is wrong since the
- * statement doesn't magically become reachable just by
- * issuing a warning. This must be
- * 'warn_about_unreachable = false' instead.
- */
- reached = true; /* only to suppress further warnings */
+ warn_about_unreachable = false;
}
}
Home |
Main Index |
Thread Index |
Old Index