Module Name: src Committed By: rillig Date: Sun Jan 17 15:06:54 UTC 2021
Modified Files: src/usr.bin/xlint/lint1: cgram.y ops.def scan.l tree.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.143 -r1.144 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.14 -r1.15 src/usr.bin/xlint/lint1/ops.def cvs rdiff -u -r1.118 -r1.119 src/usr.bin/xlint/lint1/scan.l cvs rdiff -u -r1.170 -r1.171 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/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.143 src/usr.bin/xlint/lint1/cgram.y:1.144 --- src/usr.bin/xlint/lint1/cgram.y:1.143 Sun Jan 17 14:55:22 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sun Jan 17 15:06:54 2021 @@ -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 @@ expr: $$ = 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); Index: src/usr.bin/xlint/lint1/ops.def diff -u src/usr.bin/xlint/lint1/ops.def:1.14 src/usr.bin/xlint/lint1/ops.def:1.15 --- src/usr.bin/xlint/lint1/ops.def:1.14 Sun Jan 17 14:55:22 2021 +++ src/usr.bin/xlint/lint1/ops.def Sun Jan 17 15:06:54 2021 @@ -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( EQ, "==", 1,1,1, , , , ,1,1,1, ,1, 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) Index: src/usr.bin/xlint/lint1/scan.l diff -u src/usr.bin/xlint/lint1/scan.l:1.118 src/usr.bin/xlint/lint1/scan.l:1.119 --- src/usr.bin/xlint/lint1/scan.l:1.118 Sat Jan 16 02:40:02 2021 +++ src/usr.bin/xlint/lint1/scan.l Sun Jan 17 15:06:54 2021 @@ -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 @@ TL ([fFlL]?[i]?) "|=" 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); Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.170 src/usr.bin/xlint/lint1/tree.c:1.171 --- src/usr.bin/xlint/lint1/tree.c:1.170 Sun Jan 17 14:55:22 2021 +++ src/usr.bin/xlint/lint1/tree.c Sun Jan 17 15:06:54 2021 @@ -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 @@ is_strict_bool(const tnode_t *tn) 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 @@ static bool 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 @@ typeok_op(op_t op, const mod_t *mp, int 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 @@ convert_constant(op_t op, int arg, type_ * 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 @@ convert_constant(op_t op, int arg, type_ /* 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 @@ fold(tnode_t *tn) 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 @@ check_expr_misc(const tnode_t *tn, bool 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 @@ check_expr_misc(const tnode_t *tn, bool case POINT: case ARROW: case NOOP: - case AND: + case BITAND: case FARG: case CASE: case INIT: @@ -4312,17 +4312,17 @@ is_confusing_precedence(op_t op, op_t lo 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;