Module Name:    src
Committed By:   rillig
Date:           Tue Jan  5 23:20:54 UTC 2021

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_324.c
        src/usr.bin/xlint/lint1: print.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_324.c
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/xlint/lint1/print.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_324.c
diff -u src/tests/usr.bin/xlint/lint1/msg_324.c:1.2 src/tests/usr.bin/xlint/lint1/msg_324.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_324.c:1.2	Tue Jan  5 22:38:51 2021
+++ src/tests/usr.bin/xlint/lint1/msg_324.c	Tue Jan  5 23:20:53 2021
@@ -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 @@ example(char c, int i, unsigned u)
 	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;
 }

Index: src/usr.bin/xlint/lint1/print.c
diff -u src/usr.bin/xlint/lint1/print.c:1.9 src/usr.bin/xlint/lint1/print.c:1.10
--- src/usr.bin/xlint/lint1/print.c:1.9	Tue Jan  5 07:37:41 2021
+++ src/usr.bin/xlint/lint1/print.c	Tue Jan  5 23:20:53 2021
@@ -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 @@ print_tnode(char *buf, size_t bufsiz, co
 		}
 		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;

Reply via email to