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: remove redundant symbolic operator...



details:   https://anonhg.NetBSD.org/src/rev/3c4fb65273f8
branches:  trunk
changeset: 1017720:3c4fb65273f8
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Jan 05 23:20:53 2021 +0000

description:
lint: remove redundant symbolic operator names

These symbolic names for INCBEF, INCAFT, DECBEF and DECAFT were
non-standard and thus confusing.  All other operators were as expected.
Now that the operator names from ops.def are very similar, there is no
need to keep to almost identical lists around.

No change to the user-visible messages since the only place where these
operator names were used was in 324, and that message was restricted to
PLUS, MINUS, MULT and SHL.

diffstat:

 tests/usr.bin/xlint/lint1/msg_324.c |  14 ++++++-
 usr.bin/xlint/lint1/print.c         |  72 +-----------------------------------
 2 files changed, 16 insertions(+), 70 deletions(-)

diffs (125 lines):

diff -r 4a19b8ba8fbe -r 3c4fb65273f8 tests/usr.bin/xlint/lint1/msg_324.c
--- a/tests/usr.bin/xlint/lint1/msg_324.c       Tue Jan 05 23:07:49 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_324.c       Tue Jan 05 23:20:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_324.c,v 1.2 2021/01/05 22:38:51 rillig Exp $       */
+/*     $NetBSD: msg_324.c,v 1.3 2021/01/05 23:20:53 rillig Exp $       */
 # 3 "msg_324.c"
 
 // Test for message: suggest cast from '%s' to '%s' on op %s to avoid overflow [324]
@@ -37,4 +37,16 @@
        l = i >> c;
        ul = u / c;
        ul = u % c;
+
+       /*
+        * Assigning the result of an increment or decrement operator to a
+        * differently-sized type is no unusual that there is no need to warn
+        * about it.  It's also more unlikely that there is an actual loss
+        * since this only happens for a single value of the old type, unlike
+        * "ul = u * u", which has many more possibilities for overflowing.
+        */
+       ul = u++;
+       ul = ++u;
+       ul = u--;
+       ul = --u;
 }
diff -r 4a19b8ba8fbe -r 3c4fb65273f8 usr.bin/xlint/lint1/print.c
--- a/usr.bin/xlint/lint1/print.c       Tue Jan 05 23:07:49 2021 +0000
+++ b/usr.bin/xlint/lint1/print.c       Tue Jan 05 23:20:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: print.c,v 1.9 2021/01/05 07:37:41 rillig Exp $ */
+/*     $NetBSD: print.c,v 1.10 2021/01/05 23:20:53 rillig Exp $        */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -35,79 +35,13 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: print.c,v 1.9 2021/01/05 07:37:41 rillig Exp $");
+__RCSID("$NetBSD: print.c,v 1.10 2021/01/05 23:20:53 rillig Exp $");
 #endif
 
 #include <stdio.h>
 
 #include "lint1.h"
 
-static const char *str_op_t[] =
-{
-       "*noop*",
-       "->",
-       ".",
-       "!",
-       "~",
-       "++",
-       "--",
-       "++<",
-       "--<",
-       "++>",
-       "-->",
-       "+",
-       "-",
-       "*",
-       "&",
-       "*",
-       "/",
-       "%",
-       "+",
-       "-",
-       "<<",
-       ">>",
-       "<",
-       "<=",
-       ">",
-       ">=",
-       "==",
-       "!=",
-       "&",
-       "^",
-       "|",
-       "&&",
-       "||",
-       "?",
-       ":",
-       "=",
-       "*=",
-       "/=",
-       "%=",
-       "+=",
-       "-=",
-       "<<=",
-       ">>=",
-       "&=",
-       "^=",
-       "|=",
-       "*name*",
-       "*constant*",
-       "*string*",
-       "*field select*",
-       "*call*",
-       ",",
-       "*(cast)*",
-       "*icall*",
-       "*load*",
-       "*push*",
-       "return",
-       "real",
-       "imag",
-       "*init*",
-       "*case*",
-       "*farg*",
-};
-
 char *
 print_tnode(char *buf, size_t bufsiz, const tnode_t *tn)
 {
@@ -148,7 +82,7 @@
                }
                break;
        default:
-               (void)snprintf(buf, bufsiz, "%s", str_op_t[tn->tn_op]);
+               (void)snprintf(buf, bufsiz, "%s", getopname(tn->tn_op));
                break;
        }
        return buf;



Home | Main Index | Thread Index | Old Index