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.
This commit is contained in:
rillig 2021-01-05 23:20:53 +00:00
parent b8104292aa
commit 15275571de
2 changed files with 16 additions and 70 deletions

View File

@ -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;
}

View File

@ -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, const tnode_t *tn)
}
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;