Tue Jan 5 23:20:54 2021 UTC ()
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.


(rillig)
diff -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_324.c
diff -r1.9 -r1.10 src/usr.bin/xlint/lint1/print.c

cvs diff -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_324.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/msg_324.c 2021/01/05 22:38:51 1.2
+++ src/tests/usr.bin/xlint/lint1/msg_324.c 2021/01/05 23:20:53 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: msg_324.c,v 1.2 2021/01/05 22:38:51 rillig Exp $ */ 1/* $NetBSD: msg_324.c,v 1.3 2021/01/05 23:20:53 rillig Exp $ */
2# 3 "msg_324.c" 2# 3 "msg_324.c"
3 3
4// Test for message: suggest cast from '%s' to '%s' on op %s to avoid overflow [324] 4// Test for message: suggest cast from '%s' to '%s' on op %s to avoid overflow [324]
5 5
6/* 6/*
7 * This warning applies to binary operators if the result of the operator 7 * This warning applies to binary operators if the result of the operator
8 * is converted to a type that is bigger than the operands' result type 8 * is converted to a type that is bigger than the operands' result type
9 * after the usual arithmetic promotions. 9 * after the usual arithmetic promotions.
10 * 10 *
11 * In such a case, the operator's result would be truncated to the operator's 11 * In such a case, the operator's result would be truncated to the operator's
12 * result type (invoking undefined behavior for signed integers), and that 12 * result type (invoking undefined behavior for signed integers), and that
13 * truncated value would then be converted. At that point, a few bits may 13 * truncated value would then be converted. At that point, a few bits may
14 * have been lost. 14 * have been lost.
@@ -27,14 +27,26 @@ example(char c, int i, unsigned u) @@ -27,14 +27,26 @@ example(char c, int i, unsigned u)
27 ul = c * u; 27 ul = c * u;
28 ul = u + c; 28 ul = u + c;
29 ul = i - u; 29 ul = i - u;
30 ul = u * i; 30 ul = u * i;
31 l = i << c; 31 l = i << c;
32 32
33 /* 33 /*
34 * The operators SHR, DIV and MOD cannot produce an overflow, 34 * The operators SHR, DIV and MOD cannot produce an overflow,
35 * therefore no warning is necessary for them. 35 * therefore no warning is necessary for them.
36 */ 36 */
37 l = i >> c; 37 l = i >> c;
38 ul = u / c; 38 ul = u / c;
39 ul = u % c; 39 ul = u % c;
 40
 41 /*
 42 * Assigning the result of an increment or decrement operator to a
 43 * differently-sized type is no unusual that there is no need to warn
 44 * about it. It's also more unlikely that there is an actual loss
 45 * since this only happens for a single value of the old type, unlike
 46 * "ul = u * u", which has many more possibilities for overflowing.
 47 */
 48 ul = u++;
 49 ul = ++u;
 50 ul = u--;
 51 ul = --u;
40} 52}

cvs diff -r1.9 -r1.10 src/usr.bin/xlint/lint1/Attic/print.c (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/Attic/print.c 2021/01/05 07:37:41 1.9
+++ src/usr.bin/xlint/lint1/Attic/print.c 2021/01/05 23:20:53 1.10
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: print.c,v 1.9 2021/01/05 07:37:41 rillig Exp $ */ 1/* $NetBSD: print.c,v 1.10 2021/01/05 23:20:53 rillig Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2003 The NetBSD Foundation, Inc. 4 * Copyright (c) 2003 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christos Zoulas. 8 * by Christos Zoulas.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -25,99 +25,33 @@ @@ -25,99 +25,33 @@
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#if HAVE_NBTOOL_CONFIG_H 32#if HAVE_NBTOOL_CONFIG_H
33#include "nbtool_config.h" 33#include "nbtool_config.h"
34#endif 34#endif
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37#ifndef lint 37#ifndef lint
38__RCSID("$NetBSD: print.c,v 1.9 2021/01/05 07:37:41 rillig Exp $"); 38__RCSID("$NetBSD: print.c,v 1.10 2021/01/05 23:20:53 rillig Exp $");
39#endif 39#endif
40 40
41#include <stdio.h> 41#include <stdio.h>
42 42
43#include "lint1.h" 43#include "lint1.h"
44 44
45static const char *str_op_t[] = 
46{ 
47 "*noop*", 
48 "->", 
49 ".", 
50 "!", 
51 "~", 
52 "++", 
53 "--", 
54 "++<", 
55 "--<", 
56 "++>", 
57 "-->", 
58 "+", 
59 "-", 
60 "*", 
61 "&", 
62 "*", 
63 "/", 
64 "%", 
65 "+", 
66 "-", 
67 "<<", 
68 ">>", 
69 "<", 
70 "<=", 
71 ">", 
72 ">=", 
73 "==", 
74 "!=", 
75 "&", 
76 "^", 
77 "|", 
78 "&&", 
79 "||", 
80 "?", 
81 ":", 
82 "=", 
83 "*=", 
84 "/=", 
85 "%=", 
86 "+=", 
87 "-=", 
88 "<<=", 
89 ">>=", 
90 "&=", 
91 "^=", 
92 "|=", 
93 "*name*", 
94 "*constant*", 
95 "*string*", 
96 "*field select*", 
97 "*call*", 
98 ",", 
99 "*(cast)*", 
100 "*icall*", 
101 "*load*", 
102 "*push*", 
103 "return", 
104 "real", 
105 "imag", 
106 "*init*", 
107 "*case*", 
108 "*farg*", 
109}; 
110 
111char * 45char *
112print_tnode(char *buf, size_t bufsiz, const tnode_t *tn) 46print_tnode(char *buf, size_t bufsiz, const tnode_t *tn)
113{ 47{
114 strg_t *st; 48 strg_t *st;
115 val_t *v; 49 val_t *v;
116 sym_t *s; 50 sym_t *s;
117 switch (tn->tn_op) { 51 switch (tn->tn_op) {
118 case NAME: 52 case NAME:
119 s = tn->tn_sym; 53 s = tn->tn_sym;
120 (void)snprintf(buf, bufsiz, "%s", s->s_name); 54 (void)snprintf(buf, bufsiz, "%s", s->s_name);
121 break; 55 break;
122 case CON: 56 case CON:
123 v = tn->tn_val; 57 v = tn->tn_val;
@@ -138,18 +72,18 @@ print_tnode(char *buf, size_t bufsiz, co @@ -138,18 +72,18 @@ print_tnode(char *buf, size_t bufsiz, co
138 st = tn->tn_string; 72 st = tn->tn_string;
139 switch (st->st_tspec) { 73 switch (st->st_tspec) {
140 case CHAR: 74 case CHAR:
141 case SCHAR: 75 case SCHAR:
142 case UCHAR: 76 case UCHAR:
143 (void)snprintf(buf, bufsiz, "\"%s\"", st->st_cp); 77 (void)snprintf(buf, bufsiz, "\"%s\"", st->st_cp);
144 break; 78 break;
145 default: 79 default:
146 (void)snprintf(buf, bufsiz, "\"*wide string*\""); 80 (void)snprintf(buf, bufsiz, "\"*wide string*\"");
147 break; 81 break;
148 } 82 }
149 break; 83 break;
150 default: 84 default:
151 (void)snprintf(buf, bufsiz, "%s", str_op_t[tn->tn_op]); 85 (void)snprintf(buf, bufsiz, "%s", getopname(tn->tn_op));
152 break; 86 break;
153 } 87 }
154 return buf; 88 return buf;
155} 89}