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 reachability for if-then-else ...
details: https://anonhg.NetBSD.org/src/rev/073d2a18b6a3
branches: trunk
changeset: 953824:073d2a18b6a3
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Mar 21 15:24:55 2021 +0000
description:
lint: fix reachability for if-then-else statements
diffstat:
tests/usr.bin/xlint/lint1/msg_130.c | 4 ++--
tests/usr.bin/xlint/lint1/msg_130.exp | 1 +
tests/usr.bin/xlint/lint1/msg_193.c | 4 ++--
tests/usr.bin/xlint/lint1/msg_193.exp | 1 +
tests/usr.bin/xlint/lint1/msg_217.c | 4 ++--
tests/usr.bin/xlint/lint1/msg_217.exp | 1 -
usr.bin/xlint/lint1/func.c | 15 ++++++++-------
7 files changed, 16 insertions(+), 14 deletions(-)
diffs (119 lines):
diff -r 993f26f14e71 -r 073d2a18b6a3 tests/usr.bin/xlint/lint1/msg_130.c
--- a/tests/usr.bin/xlint/lint1/msg_130.c Sun Mar 21 14:49:21 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_130.c Sun Mar 21 15:24:55 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_130.c,v 1.11 2021/03/10 00:02:00 rillig Exp $ */
+/* $NetBSD: msg_130.c,v 1.12 2021/03/21 15:24:56 rillig Exp $ */
# 3 "msg_130.c"
// Test for message: enum type mismatch: '%s' '%s' '%s' [130]
@@ -89,7 +89,7 @@
if (sizeof_int == sizeof_uint) /* expect: 130 *//* FIXME */
return 6;
- return 0;
+ return 0; /* expect: statement not reached */
}
/*
diff -r 993f26f14e71 -r 073d2a18b6a3 tests/usr.bin/xlint/lint1/msg_130.exp
--- a/tests/usr.bin/xlint/lint1/msg_130.exp Sun Mar 21 14:49:21 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_130.exp Sun Mar 21 15:24:55 2021 +0000
@@ -2,4 +2,5 @@
msg_130.c(31): warning: enum type mismatch: 'enum color' '!=' 'enum size' [130]
msg_130.c(32): warning: enum type mismatch: 'enum color' '==' 'enum size' [130]
msg_130.c(89): warning: enum type mismatch: 'enum <unnamed>' '==' 'enum <unnamed>' [130]
+msg_130.c(92): warning: statement not reached [193]
msg_130.c(127): warning: enum type mismatch: 'enum <unnamed>' '==' 'enum <unnamed>' [130]
diff -r 993f26f14e71 -r 073d2a18b6a3 tests/usr.bin/xlint/lint1/msg_193.c
--- a/tests/usr.bin/xlint/lint1/msg_193.c Sun Mar 21 14:49:21 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_193.c Sun Mar 21 15:24:55 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_193.c,v 1.4 2021/03/21 14:36:59 rillig Exp $ */
+/* $NetBSD: msg_193.c,v 1.5 2021/03/21 15:24:56 rillig Exp $ */
# 3 "msg_193.c"
// Test for message: statement not reached [193]
@@ -140,7 +140,7 @@
{
if (1)
return;
- unreachable(); /* TODO: expect: 193 */
+ unreachable(); /* expect: 193 */
}
void
diff -r 993f26f14e71 -r 073d2a18b6a3 tests/usr.bin/xlint/lint1/msg_193.exp
--- a/tests/usr.bin/xlint/lint1/msg_193.exp Sun Mar 21 14:49:21 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_193.exp Sun Mar 21 15:24:55 2021 +0000
@@ -10,6 +10,7 @@
msg_193.c(128): warning: statement not reached [193]
msg_193.c(131): warning: statement not reached [193]
msg_193.c(133): warning: statement not reached [193]
+msg_193.c(143): warning: statement not reached [193]
msg_193.c(152): warning: statement not reached [193]
msg_193.c(161): warning: statement not reached [193]
msg_193.c(169): warning: statement not reached [193]
diff -r 993f26f14e71 -r 073d2a18b6a3 tests/usr.bin/xlint/lint1/msg_217.c
--- a/tests/usr.bin/xlint/lint1/msg_217.c Sun Mar 21 14:49:21 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_217.c Sun Mar 21 15:24:55 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_217.c,v 1.8 2021/03/21 14:36:59 rillig Exp $ */
+/* $NetBSD: msg_217.c,v 1.9 2021/03/21 15:24:56 rillig Exp $ */
# 3 "msg_217.c"
// Test for message: function %s falls off bottom without returning value [217]
@@ -55,7 +55,7 @@
continue;
break;
}
-} /* FIXME *//* expect: 217 */
+}
int
unreachable_continue_falls_through(void)
diff -r 993f26f14e71 -r 073d2a18b6a3 tests/usr.bin/xlint/lint1/msg_217.exp
--- a/tests/usr.bin/xlint/lint1/msg_217.exp Sun Mar 21 14:49:21 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_217.exp Sun Mar 21 15:24:55 2021 +0000
@@ -1,4 +1,3 @@
msg_217.c(11): warning: function random falls off bottom without returning value [217]
-msg_217.c(58): warning: function reachable_continue_leads_to_endless_loop falls off bottom without returning value [217]
msg_217.c(65): warning: statement not reached [193]
msg_217.c(68): warning: function unreachable_continue_falls_through falls off bottom without returning value [217]
diff -r 993f26f14e71 -r 073d2a18b6a3 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c Sun Mar 21 14:49:21 2021 +0000
+++ b/usr.bin/xlint/lint1/func.c Sun Mar 21 15:24:55 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: func.c,v 1.89 2021/03/21 14:49:21 rillig Exp $ */
+/* $NetBSD: func.c,v 1.90 2021/03/21 15:24:55 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.89 2021/03/21 14:49:21 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.90 2021/03/21 15:24:55 rillig Exp $");
#endif
#include <stdlib.h>
@@ -631,12 +631,13 @@
void
if3(bool els)
{
+ if (cstmt->c_reached_end_of_then)
+ reached = true;
+ else if (cstmt->c_always_then)
+ reached = false;
+ else if (!els)
+ reached = true;
- if (els) {
- reached |= cstmt->c_reached_end_of_then;
- } else {
- reached = true;
- }
popctrl(T_IF);
}
Home |
Main Index |
Thread Index |
Old Index