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: rename mod_t.m_requires_bool to m_...



details:   https://anonhg.NetBSD.org/src/rev/e74fbcd89463
branches:  trunk
changeset: 366797:e74fbcd89463
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Jun 15 18:29:21 2022 +0000

description:
lint: rename mod_t.m_requires_bool to m_compares_with_zero

The operators NOT, LOGAND, LOGOR and QUEST only require _Bool in strict
bool mode, in default mode they accept any scalar expression and compare
it with zero.  The new names are more accurate.

No functional change.

diffstat:

 usr.bin/xlint/lint1/ckbool.c   |  13 +++++++------
 usr.bin/xlint/lint1/externs1.h |   4 ++--
 usr.bin/xlint/lint1/func.c     |   6 +++---
 usr.bin/xlint/lint1/op.h       |   6 +++---
 usr.bin/xlint/lint1/tree.c     |  14 +++++++-------
 5 files changed, 22 insertions(+), 21 deletions(-)

diffs (182 lines):

diff -r 34697ec994cb -r e74fbcd89463 usr.bin/xlint/lint1/ckbool.c
--- a/usr.bin/xlint/lint1/ckbool.c      Wed Jun 15 18:19:42 2022 +0000
+++ b/usr.bin/xlint/lint1/ckbool.c      Wed Jun 15 18:29:21 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ckbool.c,v 1.16 2022/06/15 18:11:02 rillig Exp $ */
+/* $NetBSD: ckbool.c,v 1.17 2022/06/15 18:29:21 rillig Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #include <sys/cdefs.h>
 
 #if defined(__RCSID)
-__RCSID("$NetBSD: ckbool.c,v 1.16 2022/06/15 18:11:02 rillig Exp $");
+__RCSID("$NetBSD: ckbool.c,v 1.17 2022/06/15 18:29:21 rillig Exp $");
 #endif
 
 #include <string.h>
@@ -158,9 +158,9 @@
            !typeok_strict_bool_binary_compatible(op, arg, ln, lt, rn, rt))
                return false;
 
-       if (mp->m_requires_bool) {
+       if (mp->m_compares_with_zero) {
                bool binary = mp->m_binary;
-               bool lbool = is_typeok_bool_operand(ln);
+               bool lbool = is_typeok_bool_compares_with_zero(ln);
                bool ok = true;
 
                if (!binary && !lbool) {
@@ -173,7 +173,8 @@
                        error(331, op_name(op), tspec_name(lt));
                        ok = false;
                }
-               if (binary && op != QUEST && !is_typeok_bool_operand(rn)) {
+               if (binary && op != QUEST &&
+                   !is_typeok_bool_compares_with_zero(rn)) {
                        /* right operand of '%s' must be bool, not '%s' */
                        error(332, op_name(op), tspec_name(rt));
                        ok = false;
@@ -212,7 +213,7 @@
  * argument with 0.
  */
 bool
-is_typeok_bool_operand(const tnode_t *tn)
+is_typeok_bool_compares_with_zero(const tnode_t *tn)
 {
        tspec_t t;
 
diff -r 34697ec994cb -r e74fbcd89463 usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Wed Jun 15 18:19:42 2022 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Wed Jun 15 18:29:21 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: externs1.h,v 1.161 2022/06/15 18:06:51 rillig Exp $    */
+/*     $NetBSD: externs1.h,v 1.162 2022/06/15 18:29:21 rillig Exp $    */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -250,7 +250,7 @@
 extern tnode_t *build_unary(op_t, bool, tnode_t *);
 extern tnode_t *build_member_access(tnode_t *, op_t, bool, sbuf_t *);
 extern tnode_t *cconv(tnode_t *);
-extern bool    is_typeok_bool_operand(const tnode_t *);
+extern bool    is_typeok_bool_compares_with_zero(const tnode_t *);
 extern bool    typeok(op_t, int, const tnode_t *, const tnode_t *);
 extern tnode_t *promote(op_t, bool, tnode_t *);
 extern tnode_t *convert(op_t, int, type_t *, tnode_t *);
diff -r 34697ec994cb -r e74fbcd89463 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c        Wed Jun 15 18:19:42 2022 +0000
+++ b/usr.bin/xlint/lint1/func.c        Wed Jun 15 18:29:21 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: func.c,v 1.139 2022/06/11 12:23:59 rillig Exp $        */
+/*     $NetBSD: func.c,v 1.140 2022/06/15 18:29:21 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: func.c,v 1.139 2022/06/11 12:23:59 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.140 2022/06/15 18:29:21 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -621,7 +621,7 @@
                return NULL;
        }
 
-       if (tn != NULL && Tflag && !is_typeok_bool_operand(tn)) {
+       if (tn != NULL && Tflag && !is_typeok_bool_compares_with_zero(tn)) {
                /* controlling expression must be bool, not '%s' */
                error(333, tspec_name(tn->tn_type->t_tspec));
        }
diff -r 34697ec994cb -r e74fbcd89463 usr.bin/xlint/lint1/op.h
--- a/usr.bin/xlint/lint1/op.h  Wed Jun 15 18:19:42 2022 +0000
+++ b/usr.bin/xlint/lint1/op.h  Wed Jun 15 18:29:21 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: op.h,v 1.19 2022/04/16 22:21:10 rillig Exp $   */
+/*     $NetBSD: op.h,v 1.20 2022/06/15 18:29:21 rillig Exp $   */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -34,13 +34,13 @@
 #include <stdbool.h>
 
 /*
- * Various information about operators
+ * Various information about operators; see ops.def.
  */
 typedef        struct {
        bool    m_binary: 1;
        bool    m_returns_bool: 1;
        bool    m_takes_bool: 1;
-       bool    m_requires_bool: 1;
+       bool    m_compares_with_zero: 1;
        bool    m_requires_integer: 1;
        bool    m_requires_integer_or_complex: 1;
        bool    m_requires_arith: 1;
diff -r 34697ec994cb -r e74fbcd89463 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Wed Jun 15 18:19:42 2022 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Wed Jun 15 18:29:21 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.452 2022/05/30 08:14:52 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.453 2022/06/15 18:29:21 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.452 2022/05/30 08:14:52 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.453 2022/06/15 18:29:21 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -726,7 +726,7 @@
         * Apply class conversions to the left operand, but only if its
         * value is needed or it is compared with zero.
         */
-       if (mp->m_value_context || mp->m_requires_bool)
+       if (mp->m_value_context || mp->m_compares_with_zero)
                ln = cconv(ln);
        /*
         * The right operand is almost always in a test or value context,
@@ -745,7 +745,7 @@
        if (mp->m_comparison)
                check_integer_comparison(op, ln, rn);
 
-       if (mp->m_value_context || mp->m_requires_bool)
+       if (mp->m_value_context || mp->m_compares_with_zero)
                ln = promote(op, false, ln);
        if (mp->m_binary && op != ARROW && op != POINT &&
            op != ASSIGN && op != RETURN && op != INIT) {
@@ -854,7 +854,7 @@
         * it is compared with zero and if this operand is a constant.
         */
        if (hflag && !constcond_flag &&
-           mp->m_requires_bool &&
+           mp->m_compares_with_zero &&
            (ln->tn_op == CON ||
             ((mp->m_binary && op != QUEST) && rn->tn_op == CON)) &&
            /* XXX: rn->tn_system_dependent should be checked as well */
@@ -866,7 +866,7 @@
        /* Fold if the operator requires it */
        if (mp->m_fold_constant_operands) {
                if (ln->tn_op == CON && (!mp->m_binary || rn->tn_op == CON)) {
-                       if (mp->m_requires_bool) {
+                       if (mp->m_compares_with_zero) {
                                ntn = fold_bool(ntn);
                        } else if (is_floating(ntn->tn_type->t_tspec)) {
                                ntn = fold_float(ntn);
@@ -4392,7 +4392,7 @@
                return;
 
        cvctx = mp->m_value_context;
-       ccond = mp->m_requires_bool;
+       ccond = mp->m_compares_with_zero;
        eq = mp->m_warn_if_operand_eq &&
             !ln->tn_parenthesized &&
             rn != NULL && !rn->tn_parenthesized;



Home | Main Index | Thread Index | Old Index