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: merge mod_t.m_test_context into m_...



details:   https://anonhg.NetBSD.org/src/rev/fd990abf3afc
branches:  trunk
changeset: 365273:fd990abf3afc
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Apr 16 22:21:10 2022 +0000

description:
lint: merge mod_t.m_test_context into m_requires_bool

These two flags mean exactly the same.

No functional change.

diffstat:

 usr.bin/xlint/lint1/ckbool.c |   6 ++--
 usr.bin/xlint/lint1/op.h     |   5 +--
 usr.bin/xlint/lint1/oper.c   |   6 ++--
 usr.bin/xlint/lint1/ops.def  |  26 ++++++++++----------
 usr.bin/xlint/lint1/tree.c   |  55 +++++++++++++++++++++----------------------
 5 files changed, 48 insertions(+), 50 deletions(-)

diffs (truncated from 370 to 300 lines):

diff -r db4f437f44e5 -r fd990abf3afc usr.bin/xlint/lint1/ckbool.c
--- a/usr.bin/xlint/lint1/ckbool.c      Sat Apr 16 21:22:12 2022 +0000
+++ b/usr.bin/xlint/lint1/ckbool.c      Sat Apr 16 22:21:10 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ckbool.c,v 1.12 2022/04/09 15:43:41 rillig Exp $ */
+/* $NetBSD: ckbool.c,v 1.13 2022/04/16 22:21:10 rillig Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #include <sys/cdefs.h>
 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: ckbool.c,v 1.12 2022/04/09 15:43:41 rillig Exp $");
+__RCSID("$NetBSD: ckbool.c,v 1.13 2022/04/16 22:21:10 rillig Exp $");
 #endif
 
 #include <string.h>
@@ -156,7 +156,7 @@
            !typeok_strict_bool_binary_compatible(op, arg, ln, lt, rn, rt))
                return false;
 
-       if (mp->m_requires_bool || op == QUEST) {
+       if (mp->m_requires_bool) {
                bool binary = mp->m_binary;
                bool lbool = is_typeok_bool_operand(ln);
                bool ok = true;
diff -r db4f437f44e5 -r fd990abf3afc usr.bin/xlint/lint1/op.h
--- a/usr.bin/xlint/lint1/op.h  Sat Apr 16 21:22:12 2022 +0000
+++ b/usr.bin/xlint/lint1/op.h  Sat Apr 16 22:21:10 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: op.h,v 1.18 2022/04/16 21:14:33 rillig Exp $   */
+/*     $NetBSD: op.h,v 1.19 2022/04/16 22:21:10 rillig Exp $   */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -47,7 +47,6 @@
        bool    m_requires_scalar: 1;
        bool    m_fold_constant_operands: 1;
        bool    m_value_context: 1;
-       bool    m_test_context: 1;
        bool    m_balance_operands: 1;
        bool    m_has_side_effect: 1;
        bool    m_warn_if_left_unsigned_in_c90: 1;
@@ -66,7 +65,7 @@
 #define op(name, repr, \
                is_binary, is_logical, takes_bool, requires_bool, \
                is_integer, is_complex, is_arithmetic, is_scalar, \
-               can_fold, is_value, is_test, balances_operands, \
+               can_fold, is_value, unused, balances_operands, \
                side_effects, left_unsigned, right_unsigned, \
                precedence_confusion, is_comparison, \
                valid_on_enum, bad_on_enum, warn_if_eq) \
diff -r db4f437f44e5 -r fd990abf3afc usr.bin/xlint/lint1/oper.c
--- a/usr.bin/xlint/lint1/oper.c        Sat Apr 16 21:22:12 2022 +0000
+++ b/usr.bin/xlint/lint1/oper.c        Sat Apr 16 22:21:10 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: oper.c,v 1.10 2021/08/02 20:58:39 rillig Exp $ */
+/*     $NetBSD: oper.c,v 1.11 2022/04/16 22:21:10 rillig Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #define op(name, repr, \
                is_binary, is_logical, takes_bool, requires_bool, \
                is_integer, is_complex, is_arithmetic, is_scalar, \
-               can_fold, is_value, is_test, balances_operands, \
+               can_fold, is_value, unused, balances_operands, \
                side_effects, left_unsigned, right_unsigned, \
                precedence_confusion, is_comparison, \
                valid_on_enum, bad_on_enum, warn_if_eq) \
@@ -48,7 +48,7 @@
                is_integer      + 0 > 0, is_complex             + 0 > 0, \
                is_arithmetic   + 0 > 0, is_scalar              + 0 > 0, \
                can_fold        + 0 > 0, is_value               + 0 > 0, \
-               is_test         + 0 > 0, balances_operands      + 0 > 0, \
+               balances_operands + 0 > 0, \
                side_effects    + 0 > 0, left_unsigned          + 0 > 0, \
                right_unsigned  + 0 > 0, precedence_confusion   + 0 > 0, \
                is_comparison   + 0 > 0, valid_on_enum          + 0 > 0, \
diff -r db4f437f44e5 -r fd990abf3afc usr.bin/xlint/lint1/ops.def
--- a/usr.bin/xlint/lint1/ops.def       Sat Apr 16 21:22:12 2022 +0000
+++ b/usr.bin/xlint/lint1/ops.def       Sat Apr 16 22:21:10 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ops.def,v 1.27 2022/04/16 21:22:12 rillig Exp $ */
+/*     $NetBSD: ops.def,v 1.28 2022/04/16 22:21:10 rillig Exp $ */
 
 begin_ops()
 
@@ -14,7 +14,7 @@
  *     warn if left operand unsigned                     x     |
  *     has side effects        - - - - - - - - - - - - x       |
  *     balance operands                              x |       |
- *     test context                                x   |       |
+ *     (unused)                                    x   |       |
  *     value context                             x     |       |
  *     fold constant operands  - - - - - - - - x       |       |
  *     requires scalar                       x |       |       |
@@ -26,11 +26,11 @@
  *     logical                   x     |       |       |       |
  *     binary                  x       |       |       |       |
  */
-/*     name    repr            b l b B i c a s f v t b s l r p c e e = */
+/*     name    repr            b l b B i c a s f v - b s l r p c e e = */
 op(    NOOP,   "no-op",         , , , , , , , , , , , , , , , , , , , )
 op(    ARROW,  "->",           1, ,1, , , , , , ,1, , , , , , , , , , )
 op(    POINT,  ".",            1, ,1, , , , , , , , , , , , , , , , , )
-op(    NOT,    "!",             ,1,1,1, , , ,1,1, ,1, , , , , , , ,1, )
+op(    NOT,    "!",             ,1,1,1, , , ,1,1, , , , , , , , , ,1, )
 op(    COMPL,  "~",             , , , , ,1, , ,1,1, , , , , , , , ,1,1)
 op(    INC,    "++",            , , , , , , , , , , , , , , , , , , , )
 op(    DEC,    "--",            , , , , , , , , , , , , , , , , , , , )
@@ -44,7 +44,7 @@
 op(    ADDR,   "&",             , ,1, , , , , , , , , , , , , , , , , )
 /* the operator 'arr[ind]' is translated to '*(arr + ind)' during parsing. */
 
-/*     name    repr            b l b B i c a s f v t b s l r p c e e = */
+/*     name    repr            b l b B i c a s f v - b s l r p c e e = */
 op(    MULT,   "*",            1, , , , , ,1, ,1,1, ,1, , ,1, , , ,1,1)
 op(    DIV,    "/",            1, , , , , ,1, ,1,1, ,1, ,1,1, , , ,1,1)
 op(    MOD,    "%",            1, , , ,1, , , ,1,1, ,1, ,1,1, , , ,1,1)
@@ -53,7 +53,7 @@
 op(    SHL,    "<<",           1, , , ,1, , , ,1,1, , , , , ,1, , ,1,1)
 op(    SHR,    ">>",           1, , , ,1, , , ,1,1, , , ,1, ,1, , ,1,1)
 
-/*     name    repr            b l b B i c a s f v t b s l r p c e e = */
+/*     name    repr            b l b B i c a s f v - b s l r p c e e = */
 op(    LT,     "<",            1,1, , , , , ,1,1,1, ,1, ,1,1, ,1,1, ,1)
 op(    LE,     "<=",           1,1, , , , , ,1,1,1, ,1, ,1,1, ,1,1, ,1)
 op(    GT,     ">",            1,1, , , , , ,1,1,1, ,1, ,1,1, ,1,1, ,1)
@@ -61,16 +61,16 @@
 op(    EQ,     "==",           1,1,1, , , , ,1,1,1, ,1, , , , ,1,1, ,1)
 op(    NE,     "!=",           1,1,1, , , , ,1,1,1, ,1, , , , ,1,1, ,1)
 
-/*     name    repr            b l b B i c a s f v t b s l r p c e e = */
+/*     name    repr            b l b B i c a s f v - b s l r p c e e = */
 op(    BITAND, "&",            1, ,1, ,1, , , ,1,1, ,1, , , ,1, , ,1, )
 op(    BITXOR, "^",            1, ,1, ,1, , , ,1,1, ,1, , , ,1, , ,1, )
 op(    BITOR,  "|",            1, ,1, ,1, , , ,1,1, ,1, , , ,1, , ,1, )
-op(    LOGAND, "&&",           1,1,1,1, , , ,1,1, ,1, , , , , , , ,1, )
-op(    LOGOR,  "||",           1,1,1,1, , , ,1,1, ,1, , , , ,1, , ,1, )
-op(    QUEST,  "?",            1, , , , , , , ,1, ,1, , , , , , , , , )
+op(    LOGAND, "&&",           1,1,1,1, , , ,1,1, , , , , , , , , ,1, )
+op(    LOGOR,  "||",           1,1,1,1, , , ,1,1, , , , , , ,1, , ,1, )
+op(    QUEST,  "?",            1, , ,1, , , , ,1, , , , , , , , , , , )
 op(    COLON,  ":",            1, ,1, , , , , , ,1, ,1, , , , , ,1, , )
 
-/*     name    repr            b l b B i c a s f v t b s l r p c e e = */
+/*     name    repr            b l b B i c a s f v - b s l r p c e e = */
 op(    ASSIGN, "=",            1, ,1, , , , , , , , , ,1, , , , ,1, , )
 op(    MULASS, "*=",           1, , , , , ,1, , , , , ,1, , , , , ,1, )
 op(    DIVASS, "/=",           1, , , , , ,1, , , , , ,1, ,1, , , ,1, )
@@ -83,7 +83,7 @@
 op(    XORASS, "^=",           1, ,1, ,1, , , , , , , ,1, , , , , ,1, )
 op(    ORASS,  "|=",           1, ,1, ,1, , , , , , , ,1, , , , , ,1, )
 
-/*     name    repr            b l b B i c a s f v t b s l r p c e e = */
+/*     name    repr            b l b B i c a s f v - b s l r p c e e = */
 op(    NAME,   "name",          , , , , , , , , , , , , , , , , , , , )
 op(    CON,    "constant",      , , , , , , , , , , , , , , , , , , , )
 op(    STRING, "string",        , , , , , , , , , , , , , , , , , , , )
@@ -105,7 +105,7 @@
 op(    IMAG,   "imag",          , , , , , , , , , , , , , , , , , , , )
 
 /* INIT, CASE and FARG are pseudo operators that don't appear in the tree. */
-/*     name    repr            b l b B i c a s f v t b s l r p c e e = */
+/*     name    repr            b l b B i c a s f v - b s l r p c e e = */
 op(    INIT,   "init",         1, ,1, , , , , , , , , ,1, , , , ,1, , )
 op(    CASE,   "case",          , , , , , , , , , , , , , , , , , , , )
 /*
diff -r db4f437f44e5 -r fd990abf3afc usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sat Apr 16 21:22:12 2022 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sat Apr 16 22:21:10 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.432 2022/04/16 21:14:33 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.433 2022/04/16 22:21: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.432 2022/04/16 21:14:33 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.433 2022/04/16 22:21:10 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -85,7 +85,7 @@
 static tnode_t *build_assignment(op_t, bool, tnode_t *, tnode_t *);
 static tnode_t *plength(type_t *);
 static tnode_t *fold(tnode_t *);
-static tnode_t *fold_test(tnode_t *);
+static tnode_t *fold_bool(tnode_t *);
 static tnode_t *fold_float(tnode_t *);
 static tnode_t *check_function_arguments(type_t *, tnode_t *);
 static tnode_t *check_prototype_argument(int, type_t *, tnode_t *);
@@ -536,7 +536,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_test_context)
+       if (mp->m_value_context || mp->m_requires_bool)
                ln = cconv(ln);
        /*
         * The right operand is almost always in a test or value context,
@@ -555,7 +555,7 @@
        if (mp->m_comparison)
                check_integer_comparison(op, ln, rn);
 
-       if (mp->m_value_context || mp->m_test_context)
+       if (mp->m_value_context || mp->m_requires_bool)
                ln = promote(op, false, ln);
        if (mp->m_binary && op != ARROW && op != POINT &&
            op != ASSIGN && op != RETURN && op != INIT) {
@@ -664,7 +664,7 @@
         * it is compared with zero and if this operand is a constant.
         */
        if (hflag && !constcond_flag &&
-           mp->m_test_context &&
+           mp->m_requires_bool &&
            (ln->tn_op == CON ||
             ((mp->m_binary && op != QUEST) && rn->tn_op == CON)) &&
            /* XXX: rn->tn_system_dependent should be checked as well */
@@ -676,8 +676,8 @@
        /* 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_test_context) {
-                               ntn = fold_test(ntn);
+                       if (mp->m_requires_bool) {
+                               ntn = fold_bool(ntn);
                        } else if (is_floating(ntn->tn_type->t_tspec)) {
                                ntn = fold_float(ntn);
                        } else {
@@ -3292,11 +3292,10 @@
 }
 
 /*
- * Fold constant nodes, as much as is needed for comparing the value with 0
- * (test context, for controlling expressions).
+ * Fold constant nodes, as much as is needed for comparing the value with 0.
  */
 static tnode_t *
-fold_test(tnode_t *tn)
+fold_bool(tnode_t *tn)
 {
        bool    l, r;
        val_t   *v;
@@ -3878,7 +3877,7 @@
  * memory which is used for the expression.
  */
 void
-expr(tnode_t *tn, bool vctx, bool tctx, bool dofreeblk, bool is_do_while)
+expr(tnode_t *tn, bool vctx, bool cond, bool dofreeblk, bool is_do_while)
 {
 
        if (tn == NULL) {       /* in case of errors */
@@ -3890,13 +3889,13 @@
        if (dcs->d_kind != DK_EXTERN && !is_do_while)
                check_statement_reachable();
 
-       check_expr_misc(tn, vctx, tctx, !tctx, false, false, false);
+       check_expr_misc(tn, vctx, cond, !cond, false, false, false);
        if (tn->tn_op == ASSIGN) {
-               if (hflag && tctx)
+               if (hflag && cond)
                        /* assignment in conditional context */
                        warning(159);
        } else if (tn->tn_op == CON) {
-               if (hflag && tctx && !constcond_flag &&
+               if (hflag && cond && !constcond_flag &&
                    !tn->tn_system_dependent &&
                    !(is_do_while &&
                      is_constcond_false(tn, tn->tn_type->t_tspec)))
@@ -3908,7 +3907,7 @@
                 * for left operands of COMMA this warning is already
                 * printed
                 */
-               if (tn->tn_op != COMMA && !vctx && !tctx)
+               if (tn->tn_op != COMMA && !vctx && !cond)
                        check_null_effect(tn);
        }
        debug_node(tn);
@@ -4054,18 +4053,18 @@
 
 static void
 check_expr_call(const tnode_t *tn, const tnode_t *ln,
-               bool szof, bool vctx, bool tctx, bool retval_discarded)
+               bool szof, bool vctx, bool cond, bool retval_discarded)
 {
        lint_assert(ln->tn_op == ADDR);
        lint_assert(ln->tn_left->tn_op == NAME);
        if (!szof &&
            !is_compiler_builtin(ln->tn_left->tn_sym->s_name))
-               outcall(tn, vctx || tctx, retval_discarded);
+               outcall(tn, vctx || cond, retval_discarded);
 }
 
 static bool



Home | Main Index | Thread Index | Old Index