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 bitwise operators



details:   https://anonhg.NetBSD.org/src/rev/b5605f4c7a50
branches:  trunk
changeset: 958710:b5605f4c7a50
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jan 17 15:06:54 2021 +0000

description:
lint: rename bitwise operators

When there are several variants of the AND operator, both of them should
get a distinguishing prefix, otherwise it's not clear which of the two
possible operators is meant by the plain AND.

diffstat:

 usr.bin/xlint/lint1/cgram.y |  10 +++++-----
 usr.bin/xlint/lint1/ops.def |   8 ++++----
 usr.bin/xlint/lint1/scan.l  |  10 +++++-----
 usr.bin/xlint/lint1/tree.c  |  36 ++++++++++++++++++------------------
 4 files changed, 32 insertions(+), 32 deletions(-)

diffs (215 lines):

diff -r f095e0c5553a -r b5605f4c7a50 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sun Jan 17 14:55:22 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sun Jan 17 15:06:54 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.143 2021/01/17 14:55:22 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.144 2021/01/17 15:06:54 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.143 2021/01/17 14:55:22 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.144 2021/01/17 15:06:54 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -1818,13 +1818,13 @@
                $$ = build($2, $1, $3);
          }
        | expr T_AND expr {
-               $$ = build(AND, $1, $3);
+               $$ = build(BITAND, $1, $3);
          }
        | expr T_XOR expr {
-               $$ = build(XOR, $1, $3);
+               $$ = build(BITXOR, $1, $3);
          }
        | expr T_OR expr {
-               $$ = build(OR, $1, $3);
+               $$ = build(BITOR, $1, $3);
          }
        | expr T_LOGAND expr {
                $$ = build(LOGAND, $1, $3);
diff -r f095e0c5553a -r b5605f4c7a50 usr.bin/xlint/lint1/ops.def
--- a/usr.bin/xlint/lint1/ops.def       Sun Jan 17 14:55:22 2021 +0000
+++ b/usr.bin/xlint/lint1/ops.def       Sun Jan 17 15:06:54 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ops.def,v 1.14 2021/01/17 14:55:22 rillig Exp $ */
+/*     $NetBSD: ops.def,v 1.15 2021/01/17 15:06:54 rillig Exp $ */
 
 begin_ops()
 
@@ -39,9 +39,9 @@
 op(    NE,     "!=",           1,1,1, , , , ,1,1,1, ,1, , , , ,1,1, ,1,1)
 
 /*     name    repr            b l b o i c a s f v t b s l r p c e e = act */
-op(    AND,    "&",            1, ,1, ,1, , , ,1,1, ,1, , , ,1, , ,1, ,1)
-op(    XOR,    "^",            1, ,1, ,1, , , ,1,1, ,1, , , ,1, , ,1, ,1)
-op(    OR,     "|",            1, ,1, ,1, , , ,1,1, ,1, , , ,1, , ,1, ,1)
+op(    BITAND, "&",            1, ,1, ,1, , , ,1,1, ,1, , , ,1, , ,1, ,1)
+op(    BITXOR, "^",            1, ,1, ,1, , , ,1,1, ,1, , , ,1, , ,1, ,1)
+op(    BITOR,  "|",            1, ,1, ,1, , , ,1,1, ,1, , , ,1, , ,1, ,1)
 op(    LOGAND, "&&",           1,1,1,1, , , ,1,1, ,1, , , , , , , ,1, ,1)
 op(    LOGOR,  "||",           1,1,1,1, , , ,1,1, ,1, , , , ,1, , ,1, ,1)
 op(    QUEST,  "?",            1, , , , , , , ,1, ,1, , , , , , , , , ,1)
diff -r f095e0c5553a -r b5605f4c7a50 usr.bin/xlint/lint1/scan.l
--- a/usr.bin/xlint/lint1/scan.l        Sun Jan 17 14:55:22 2021 +0000
+++ b/usr.bin/xlint/lint1/scan.l        Sun Jan 17 15:06:54 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: scan.l,v 1.118 2021/01/16 02:40:02 rillig Exp $ */
+/* $NetBSD: scan.l,v 1.119 2021/01/17 15:06:54 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: scan.l,v 1.118 2021/01/16 02:40:02 rillig Exp $");
+__RCSID("$NetBSD: scan.l,v 1.119 2021/01/17 15:06:54 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -124,9 +124,9 @@
 "|="                           return operator(T_OPASS, ORASS);
 "||"                           return operator(T_LOGOR, LOGOR);
 "&&"                           return operator(T_LOGAND, LOGAND);
-"|"                            return operator(T_OR, OR);
-"&"                            return operator(T_AND, AND);
-"^"                            return operator(T_XOR, XOR);
+"|"                            return operator(T_OR, BITOR);
+"&"                            return operator(T_AND, BITAND);
+"^"                            return operator(T_XOR, BITXOR);
 "=="                           return operator(T_EQOP, EQ);
 "!="                           return operator(T_EQOP, NE);
 "<"                            return operator(T_RELOP, LT);
diff -r f095e0c5553a -r b5605f4c7a50 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sun Jan 17 14:55:22 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sun Jan 17 15:06:54 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.170 2021/01/17 14:55:22 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.171 2021/01/17 15:06:54 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.170 2021/01/17 14:55:22 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.171 2021/01/17 15:06:54 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -737,7 +737,7 @@
                return true;
 
        /* For enums that are used as bit sets, allow "flags & FLAG". */
-       if (tn->tn_op == AND &&
+       if (tn->tn_op == BITAND &&
            tn->tn_left->tn_op == CVT &&
            tn->tn_left->tn_type->t_tspec == INT && !tn->tn_left->tn_cast &&
            tn->tn_left->tn_left->tn_type->t_tspec == ENUM &&
@@ -1099,7 +1099,7 @@
 needs_compatible_types(op_t op)
 {
        return op == EQ || op == NE ||
-              op == AND || op == XOR || op == OR ||
+              op == BITAND || op == BITXOR || op == BITOR ||
               op == COLON ||
               op == ASSIGN || op == ANDASS || op == XORASS || op == ORASS ||
               op == RETURN ||
@@ -1384,9 +1384,9 @@
        case NAME:
        case LOGOR:
        case LOGAND:
-       case OR:
-       case XOR:
-       case AND:
+       case BITOR:
+       case BITXOR:
+       case BITAND:
        case MOD:
        case DIV:
        case MULT:
@@ -2362,7 +2362,7 @@
                 * For bitwise operations we are not interested in the
                 * value, but in the bits itself.
                 */
-               if (op == ORASS || op == OR || op == XOR) {
+               if (op == ORASS || op == BITOR || op == BITXOR) {
                        /*
                         * Print a warning if bits which were set are
                         * lost due to the conversion.
@@ -2372,7 +2372,7 @@
                                /* constant truncated by conv., op %s */
                                warning(306, modtab[op].m_name);
                        }
-               } else if (op == ANDASS || op == AND) {
+               } else if (op == ANDASS || op == BITAND) {
                        /*
                         * Print a warning if additional bits are not all 1
                         * and the most significant bit of the old value is 1,
@@ -3120,13 +3120,13 @@
        case NE:
                q = (utyp ? ul != ur : sl != sr) ? 1 : 0;
                break;
-       case AND:
+       case BITAND:
                q = utyp ? (int64_t)(ul & ur) : sl & sr;
                break;
-       case XOR:
+       case BITXOR:
                q = utyp ? (int64_t)(ul ^ ur) : sl ^ sr;
                break;
-       case OR:
+       case BITOR:
                q = utyp ? (int64_t)(ul | ur) : sl | sr;
                break;
        default:
@@ -3976,8 +3976,8 @@
        case STRING:
                return;
                /* LINTED206: (enumeration values not handled in switch) */
-       case OR:
-       case XOR:
+       case BITOR:
+       case BITXOR:
        case NE:
        case GE:
        case GT:
@@ -4000,7 +4000,7 @@
        case POINT:
        case ARROW:
        case NOOP:
-       case AND:
+       case BITAND:
        case FARG:
        case CASE:
        case INIT:
@@ -4312,17 +4312,17 @@
                return false;
        }
 
-       lint_assert(op == AND || op == XOR || op == OR);
+       lint_assert(op == BITAND || op == BITXOR || op == BITOR);
        if (!lparen && lop != op) {
                if (lop == PLUS || lop == MINUS)
                        return true;
-               if (lop == AND || lop == XOR)
+               if (lop == BITAND || lop == BITXOR)
                        return true;
        }
        if (!rparen && rop != op) {
                if (rop == PLUS || rop == MINUS)
                        return true;
-               if (rop == AND || rop == XOR)
+               if (rop == BITAND || rop == BITXOR)
                        return true;
        }
        return false;



Home | Main Index | Thread Index | Old Index