Module Name:    src
Committed By:   rillig
Date:           Sun Mar 21 19:08:10 UTC 2021

Modified Files:
        src/usr.bin/xlint/lint1: externs1.h func.c tree.c

Log Message:
lint: invert 'rchflag', call it warn_about_unreachable instead

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.93 -r1.94 src/usr.bin/xlint/lint1/func.c
cvs rdiff -u -r1.244 -r1.245 src/usr.bin/xlint/lint1/tree.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.81 src/usr.bin/xlint/lint1/externs1.h:1.82
--- src/usr.bin/xlint/lint1/externs1.h:1.81	Sun Mar 21 14:49:21 2021
+++ src/usr.bin/xlint/lint1/externs1.h	Sun Mar 21 19:08:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs1.h,v 1.81 2021/03/21 14:49:21 rillig Exp $	*/
+/*	$NetBSD: externs1.h,v 1.82 2021/03/21 19:08:10 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -235,7 +235,7 @@ extern	void	debug_node(const tnode_t *, 
  */
 extern	sym_t	*funcsym;
 extern	bool	reached;
-extern	bool	rchflg;
+extern	bool	warn_about_unreachable;
 extern	bool	seen_fallthrough;
 extern	int	nargusg;
 extern	pos_t	argsused_pos;

Index: src/usr.bin/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.93 src/usr.bin/xlint/lint1/func.c:1.94
--- src/usr.bin/xlint/lint1/func.c:1.93	Sun Mar 21 18:58:34 2021
+++ src/usr.bin/xlint/lint1/func.c	Sun Mar 21 19:08:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: func.c,v 1.93 2021/03/21 18:58:34 rillig Exp $	*/
+/*	$NetBSD: func.c,v 1.94 2021/03/21 19:08:10 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.93 2021/03/21 18:58:34 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.94 2021/03/21 19:08:10 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -56,10 +56,10 @@ sym_t	*funcsym;
 bool	reached = true;
 
 /*
- * Is set as long as NOTREACHED is in effect.
- * Is reset everywhere where reached can become 0.
+ * Is true by default, can be cleared by NOTREACHED.
+ * Is reset to true whenever 'reached' changes.
  */
-bool	rchflg;
+bool	warn_about_unreachable;
 
 /*
  * In conjunction with 'reached', controls printing of "fallthrough on ..."
@@ -191,7 +191,7 @@ static void
 set_reached(bool new_reached)
 {
 	reached = new_reached;
-	rchflg = false;
+	warn_about_unreachable = true;
 }
 
 /*
@@ -200,13 +200,14 @@ set_reached(bool new_reached)
 void
 check_statement_reachable(void)
 {
-	if (!reached && !rchflg) {
+	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 'rchflg = true' instead.
+		 * issuing a warning.  This must be
+		 * 'warn_about_unreachable = false' instead.
 		 */
 		reached = true;	/* only to suppress further warnings */
 	}
@@ -930,7 +931,7 @@ for2(void)
 	csrc_pos = cstmt->c_cfpos;
 
 	/* simply "statement not reached" would be confusing */
-	if (!reached && !rchflg) {
+	if (!reached && warn_about_unreachable) {
 		/* end-of-loop code not reached */
 		warning(223);
 		set_reached(true);
@@ -1271,7 +1272,7 @@ not_reached(int n)
 {
 
 	set_reached(false);
-	rchflg = true;
+	warn_about_unreachable = false;
 }
 
 /* ARGSUSED */

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.244 src/usr.bin/xlint/lint1/tree.c:1.245
--- src/usr.bin/xlint/lint1/tree.c:1.244	Sun Mar 21 18:58:34 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sun Mar 21 19:08:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.244 2021/03/21 18:58:34 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.245 2021/03/21 19:08:10 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.244 2021/03/21 18:58:34 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.245 2021/03/21 19:08:10 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -3927,8 +3927,8 @@ check_expr_misc(const tnode_t *tn, bool 
 
 	switch (op) {
 	case ADDR:
-		/* XXX: Taking rchflg into account here feels wrong. */
-		if (ln->tn_op == NAME && (reached || rchflg)) {
+		/* XXX: Taking warn_about_unreachable into account here feels wrong. */
+		if (ln->tn_op == NAME && (reached || !warn_about_unreachable)) {
 			if (!szof)
 				mark_as_set(ln->tn_sym);
 			mark_as_used(ln->tn_sym, fcall, szof);
@@ -3959,8 +3959,8 @@ check_expr_misc(const tnode_t *tn, bool 
 	case SHRASS:
 	case REAL:
 	case IMAG:
-		/* XXX: Taking rchflg into account here feels wrong. */
-		if (ln->tn_op == NAME && (reached || rchflg)) {
+		/* XXX: Taking warn_about_unreachable into account here feels wrong. */
+		if (ln->tn_op == NAME && (reached || !warn_about_unreachable)) {
 			sc = ln->tn_sym->s_scl;
 			/*
 			 * Look if there was a asm statement in one of the
@@ -3981,8 +3981,8 @@ check_expr_misc(const tnode_t *tn, bool 
 		}
 		break;
 	case ASSIGN:
-		/* XXX: Taking rchflg into account here feels wrong. */
-		if (ln->tn_op == NAME && !szof && (reached || rchflg)) {
+		/* XXX: Taking warn_about_unreachable into account here feels wrong. */
+		if (ln->tn_op == NAME && !szof && (reached || !warn_about_unreachable)) {
 			mark_as_set(ln->tn_sym);
 			if (ln->tn_sym->s_scl == EXTERN)
 				outusg(ln->tn_sym);

Reply via email to