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: invert 'rchflag', call it warn_abo...



details:   https://anonhg.NetBSD.org/src/rev/b1beb55d4868
branches:  trunk
changeset: 981815:b1beb55d4868
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Mar 21 19:08:10 2021 +0000

description:
lint: invert 'rchflag', call it warn_about_unreachable instead

No functional change.

diffstat:

 usr.bin/xlint/lint1/externs1.h |   4 ++--
 usr.bin/xlint/lint1/func.c     |  21 +++++++++++----------
 usr.bin/xlint/lint1/tree.c     |  16 ++++++++--------
 3 files changed, 21 insertions(+), 20 deletions(-)

diffs (145 lines):

diff -r f6430af1c557 -r b1beb55d4868 usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Sun Mar 21 18:58:34 2021 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Sun Mar 21 19:08:10 2021 +0000
@@ -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 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;
diff -r f6430af1c557 -r b1beb55d4868 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c        Sun Mar 21 18:58:34 2021 +0000
+++ b/usr.bin/xlint/lint1/func.c        Sun Mar 21 19:08:10 2021 +0000
@@ -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 @@
 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 @@
 set_reached(bool new_reached)
 {
        reached = new_reached;
-       rchflg = false;
+       warn_about_unreachable = true;
 }
 
 /*
@@ -200,13 +200,14 @@
 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 @@
        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 @@
 {
 
        set_reached(false);
-       rchflg = true;
+       warn_about_unreachable = false;
 }
 
 /* ARGSUSED */
diff -r f6430af1c557 -r b1beb55d4868 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sun Mar 21 18:58:34 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sun Mar 21 19:08:10 2021 +0000
@@ -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 @@
 
        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 @@
        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 @@
                }
                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);



Home | Main Index | Thread Index | Old Index