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: fix wrong 'statement not reached' ...
details: https://anonhg.NetBSD.org/src/rev/4773187fa91e
branches: trunk
changeset: 953811:4773187fa91e
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Mar 21 11:48:04 2021 +0000
description:
lint: fix wrong 'statement not reached' in do-while loop
diffstat:
tests/usr.bin/xlint/lint1/msg_217.c | 11 ++++++-----
tests/usr.bin/xlint/lint1/msg_217.exp | 3 +--
usr.bin/xlint/lint1/tree.c | 7 ++++---
3 files changed, 11 insertions(+), 10 deletions(-)
diffs (67 lines):
diff -r 816c13ec32cc -r 4773187fa91e tests/usr.bin/xlint/lint1/msg_217.c
--- a/tests/usr.bin/xlint/lint1/msg_217.c Sun Mar 21 11:38:24 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_217.c Sun Mar 21 11:48:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_217.c,v 1.4 2021/02/21 09:17:55 rillig Exp $ */
+/* $NetBSD: msg_217.c,v 1.5 2021/03/21 11:48:04 rillig Exp $ */
# 3 "msg_217.c"
// Test for message: function %s falls off bottom without returning value [217]
@@ -19,16 +19,17 @@
* Seen in external/bsd/libevent/dist/event_tagging.c, function
* encode_int_internal.
*
- * As of 2021-01-31, lint wrongly reports that the function would fall off
- * the bottom, but it cannot reach the bottom since every path contains the
- * 'return i'.
+ * Before tree.c 1.243 from 2021-03-21, lint wrongly reported that the
+ * 'while 0' was unreachable. This has been fixed by allowing the 'while 0'
+ * in a do-while-false loop to be unreachable. The same could be useful for a
+ * do-while-true.
*/
int
do_while_return(int i)
{
do {
return i;
- } while (/*CONSTCOND*/0); /*FIXME*//* expect: 193 */
+ } while (0);
} /*FIXME*//* expect: 217 */
/*
diff -r 816c13ec32cc -r 4773187fa91e tests/usr.bin/xlint/lint1/msg_217.exp
--- a/tests/usr.bin/xlint/lint1/msg_217.exp Sun Mar 21 11:38:24 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_217.exp Sun Mar 21 11:48:04 2021 +0000
@@ -1,3 +1,2 @@
msg_217.c(11): warning: function random falls off bottom without returning value [217]
-msg_217.c(31): warning: statement not reached [193]
-msg_217.c(32): warning: function do_while_return falls off bottom without returning value [217]
+msg_217.c(33): warning: function do_while_return falls off bottom without returning value [217]
diff -r 816c13ec32cc -r 4773187fa91e usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Sun Mar 21 11:38:24 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c Sun Mar 21 11:48:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.242 2021/03/20 21:08:09 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.243 2021/03/21 11:48:04 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.242 2021/03/20 21:08:09 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.243 2021/03/21 11:48:04 rillig Exp $");
#endif
#include <float.h>
@@ -3777,7 +3777,8 @@
}
/* expr() is also called in global initializations */
- if (dcs->d_ctx != EXTERN)
+ /* TODO: rename constcond_false_ok */
+ if (dcs->d_ctx != EXTERN && !constcond_false_ok)
check_statement_reachable();
check_expr_misc(tn, vctx, tctx, !tctx, false, false, false);
Home |
Main Index |
Thread Index |
Old Index