Fri Jan 1 11:58:03 2021 UTC ()
lint: rename styp and utyp


(rillig)
diff -r1.19 -r1.20 src/usr.bin/xlint/common/lint.h
diff -r1.113 -r1.114 src/usr.bin/xlint/lint1/tree.c
diff -r1.29 -r1.30 src/usr.bin/xlint/lint2/chk.c

cvs diff -r1.19 -r1.20 src/usr.bin/xlint/common/lint.h (expand / switch to unified diff)

--- src/usr.bin/xlint/common/lint.h 2021/01/01 11:51:15 1.19
+++ src/usr.bin/xlint/common/lint.h 2021/01/01 11:58:03 1.20
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lint.h,v 1.19 2021/01/01 11:51:15 rillig Exp $ */ 1/* $NetBSD: lint.h,v 1.20 2021/01/01 11:58:03 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1994, 1995 Jochen Pohl 4 * Copyright (c) 1994, 1995 Jochen Pohl
5 * All Rights Reserved. 5 * All Rights Reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -83,41 +83,41 @@ typedef enum { @@ -83,41 +83,41 @@ typedef enum {
83 DCOMPLEX, /* double _Complex */ 83 DCOMPLEX, /* double _Complex */
84 LCOMPLEX /* long double _Complex */ 84 LCOMPLEX /* long double _Complex */
85#define NTSPEC (LCOMPLEX + 1) 85#define NTSPEC (LCOMPLEX + 1)
86} tspec_t; 86} tspec_t;
87 87
88 88
89/* 89/*
90 * size of types, name and classification 90 * size of types, name and classification
91 */ 91 */
92typedef struct { 92typedef struct {
93 size_t tt_sz; /* size in bits */ 93 size_t tt_sz; /* size in bits */
94 size_t tt_psz; /* size, different from tt_sz 94 size_t tt_psz; /* size, different from tt_sz
95 if pflag is set */ 95 if pflag is set */
96 tspec_t tt_styp; /* signed counterpart */ 96 tspec_t tt_signed_counterpart;
97 tspec_t tt_utyp; /* unsigned counterpart */ 97 tspec_t tt_unsigned_counterpart;
98 u_int tt_is_int : 1; /* 1 if integer type */ 98 u_int tt_is_int : 1; /* 1 if integer type */
99 u_int tt_is_uint : 1; /* 1 if unsigned integer type */ 99 u_int tt_is_uint : 1; /* 1 if unsigned integer type */
100 u_int tt_is_float : 1; /* 1 if floating point type */ 100 u_int tt_is_float : 1; /* 1 if floating point type */
101 u_int tt_is_arith : 1; /* 1 if arithmetic type */ 101 u_int tt_is_arith : 1; /* 1 if arithmetic type */
102 u_int tt_is_scalar : 1; /* 1 if scalar type */ 102 u_int tt_is_scalar : 1; /* 1 if scalar type */
103 u_int tt_is_complex : 1; /* 1 if complex type */ 103 u_int tt_is_complex : 1; /* 1 if complex type */
104 const char *tt_name; /* name of the type */ 104 const char *tt_name; /* name of the type */
105} ttab_t; 105} ttab_t;
106 106
107#define size(t) (ttab[t].tt_sz) 107#define size(t) (ttab[t].tt_sz)
108#define psize(t) (ttab[t].tt_psz) 108#define psize(t) (ttab[t].tt_psz)
109#define styp(t) (ttab[t].tt_styp) 109#define signed_type(t) (ttab[t].tt_signed_counterpart)
110#define utyp(t) (ttab[t].tt_utyp) 110#define unsigned_type(t) (ttab[t].tt_unsigned_counterpart)
111#define tspec_is_int(t) (ttab[t].tt_is_int) 111#define tspec_is_int(t) (ttab[t].tt_is_int)
112#define tspec_is_uint(t) (ttab[t].tt_is_uint) 112#define tspec_is_uint(t) (ttab[t].tt_is_uint)
113#define tspec_is_float(t) (ttab[t].tt_is_float) 113#define tspec_is_float(t) (ttab[t].tt_is_float)
114#define tspec_is_arith(t) (ttab[t].tt_is_arith) 114#define tspec_is_arith(t) (ttab[t].tt_is_arith)
115#define tspec_is_complex(t) (ttab[t].tt_is_complex) 115#define tspec_is_complex(t) (ttab[t].tt_is_complex)
116#define tspec_is_scalar(t) (ttab[t].tt_is_scalar) 116#define tspec_is_scalar(t) (ttab[t].tt_is_scalar)
117 117
118extern ttab_t ttab[]; 118extern ttab_t ttab[];
119 119
120 120
121typedef enum { 121typedef enum {
122 NODECL, /* not declared until now */ 122 NODECL, /* not declared until now */
123 DECL, /* declared */ 123 DECL, /* declared */

cvs diff -r1.113 -r1.114 src/usr.bin/xlint/lint1/tree.c (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/tree.c 2021/01/01 11:41:01 1.113
+++ src/usr.bin/xlint/lint1/tree.c 2021/01/01 11:58:03 1.114
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tree.c,v 1.113 2021/01/01 11:41:01 rillig Exp $ */ 1/* $NetBSD: tree.c,v 1.114 2021/01/01 11:58:03 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1994, 1995 Jochen Pohl 4 * Copyright (c) 1994, 1995 Jochen Pohl
5 * All Rights Reserved. 5 * All Rights Reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -27,27 +27,27 @@ @@ -27,27 +27,27 @@
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#if HAVE_NBTOOL_CONFIG_H 34#if HAVE_NBTOOL_CONFIG_H
35#include "nbtool_config.h" 35#include "nbtool_config.h"
36#endif 36#endif
37 37
38#include <sys/cdefs.h> 38#include <sys/cdefs.h>
39#if defined(__RCSID) && !defined(lint) 39#if defined(__RCSID) && !defined(lint)
40__RCSID("$NetBSD: tree.c,v 1.113 2021/01/01 11:41:01 rillig Exp $"); 40__RCSID("$NetBSD: tree.c,v 1.114 2021/01/01 11:58:03 rillig Exp $");
41#endif 41#endif
42 42
43#include <float.h> 43#include <float.h>
44#include <limits.h> 44#include <limits.h>
45#include <math.h> 45#include <math.h>
46#include <signal.h> 46#include <signal.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <string.h> 48#include <string.h>
49 49
50#include "lint1.h" 50#include "lint1.h"
51#include "cgram.h" 51#include "cgram.h"
52#include "externs1.h" 52#include "externs1.h"
53 53
@@ -1656,27 +1656,27 @@ balance(op_t op, tnode_t **lnp, tnode_t  @@ -1656,27 +1656,27 @@ balance(op_t op, tnode_t **lnp, tnode_t
1656 } 1656 }
1657 t = tl[i]; 1657 t = tl[i];
1658 } 1658 }
1659 } 1659 }
1660 } else { 1660 } else {
1661 /* Keep unsigned in traditional C */ 1661 /* Keep unsigned in traditional C */
1662 u = tspec_is_uint(lt) || tspec_is_uint(rt); 1662 u = tspec_is_uint(lt) || tspec_is_uint(rt);
1663 for (i = 0; tl[i] != INT; i++) { 1663 for (i = 0; tl[i] != INT; i++) {
1664 if (lt == tl[i] || rt == tl[i]) 1664 if (lt == tl[i] || rt == tl[i])
1665 break; 1665 break;
1666 } 1666 }
1667 t = tl[i]; 1667 t = tl[i];
1668 if (u && tspec_is_int(t) && !tspec_is_uint(t)) 1668 if (u && tspec_is_int(t) && !tspec_is_uint(t))
1669 t = utyp(t); 1669 t = unsigned_type(t);
1670 } 1670 }
1671 1671
1672 if (t != lt) { 1672 if (t != lt) {
1673 ntp = tduptyp((*lnp)->tn_type); 1673 ntp = tduptyp((*lnp)->tn_type);
1674 ntp->t_tspec = t; 1674 ntp->t_tspec = t;
1675 *lnp = convert(op, 0, ntp, *lnp); 1675 *lnp = convert(op, 0, ntp, *lnp);
1676 } 1676 }
1677 if (t != rt) { 1677 if (t != rt) {
1678 ntp = tduptyp((*rnp)->tn_type); 1678 ntp = tduptyp((*rnp)->tn_type);
1679 ntp->t_tspec = t; 1679 ntp->t_tspec = t;
1680 *rnp = convert(op, 0, ntp, *rnp); 1680 *rnp = convert(op, 0, ntp, *rnp);
1681 } 1681 }
1682} 1682}
@@ -1765,27 +1765,27 @@ check_prototype_conversion(int arg, tspe @@ -1765,27 +1765,27 @@ check_prototype_conversion(int arg, tspe
1765 if (!tspec_is_int(ot) || psize(ot) > psize(INT)) { 1765 if (!tspec_is_int(ot) || psize(ot) > psize(INT)) {
1766 /* conversion to '%s' due to prototype, arg #%d */ 1766 /* conversion to '%s' due to prototype, arg #%d */
1767 warning(259, tyname(buf, sizeof(buf), tp), arg); 1767 warning(259, tyname(buf, sizeof(buf), tp), arg);
1768 } 1768 }
1769 } else if (hflag) { 1769 } else if (hflag) {
1770 /* 1770 /*
1771 * they differ in sign or base type (char, short, int, 1771 * they differ in sign or base type (char, short, int,
1772 * long, long long, float, double, long double) 1772 * long, long long, float, double, long double)
1773 * 1773 *
1774 * if they differ only in sign and the argument is a constant 1774 * if they differ only in sign and the argument is a constant
1775 * and the msb of the argument is not set, print no warning 1775 * and the msb of the argument is not set, print no warning
1776 */ 1776 */
1777 if (ptn->tn_op == CON && tspec_is_int(nt) && 1777 if (ptn->tn_op == CON && tspec_is_int(nt) &&
1778 styp(nt) == styp(ot) && 1778 signed_type(nt) == signed_type(ot) &&
1779 msb(ptn->tn_val->v_quad, ot, -1) == 0) { 1779 msb(ptn->tn_val->v_quad, ot, -1) == 0) {
1780 /* ok */ 1780 /* ok */
1781 } else { 1781 } else {
1782 /* conversion to '%s' due to prototype, arg #%d */ 1782 /* conversion to '%s' due to prototype, arg #%d */
1783 warning(259, tyname(buf, sizeof(buf), tp), arg); 1783 warning(259, tyname(buf, sizeof(buf), tp), arg);
1784 } 1784 }
1785 } 1785 }
1786} 1786}
1787 1787
1788/* 1788/*
1789 * Print warnings for conversions of integer types which may cause problems. 1789 * Print warnings for conversions of integer types which may cause problems.
1790 */ 1790 */
1791/* ARGSUSED */ 1791/* ARGSUSED */

cvs diff -r1.29 -r1.30 src/usr.bin/xlint/lint2/chk.c (expand / switch to unified diff)

--- src/usr.bin/xlint/lint2/chk.c 2020/12/30 10:46:11 1.29
+++ src/usr.bin/xlint/lint2/chk.c 2021/01/01 11:58:03 1.30
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: chk.c,v 1.29 2020/12/30 10:46:11 rillig Exp $ */ 1/* $NetBSD: chk.c,v 1.30 2021/01/01 11:58:03 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. 4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
5 * Copyright (c) 1994, 1995 Jochen Pohl 5 * Copyright (c) 1994, 1995 Jochen Pohl
6 * All Rights Reserved. 6 * All Rights Reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -28,27 +28,27 @@ @@ -28,27 +28,27 @@
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34 34
35#if HAVE_NBTOOL_CONFIG_H 35#if HAVE_NBTOOL_CONFIG_H
36#include "nbtool_config.h" 36#include "nbtool_config.h"
37#endif 37#endif
38 38
39#include <sys/cdefs.h> 39#include <sys/cdefs.h>
40#if defined(__RCSID) && !defined(lint) 40#if defined(__RCSID) && !defined(lint)
41__RCSID("$NetBSD: chk.c,v 1.29 2020/12/30 10:46:11 rillig Exp $"); 41__RCSID("$NetBSD: chk.c,v 1.30 2021/01/01 11:58:03 rillig Exp $");
42#endif 42#endif
43 43
44#include <ctype.h> 44#include <ctype.h>
45#include <limits.h> 45#include <limits.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <string.h> 47#include <string.h>
48 48
49#include "lint2.h" 49#include "lint2.h"
50 50
51static void chkund(hte_t *); 51static void chkund(hte_t *);
52static void chkdnu(hte_t *); 52static void chkdnu(hte_t *);
53static void chkdnud(hte_t *); 53static void chkdnud(hte_t *);
54static void chkmd(hte_t *); 54static void chkmd(hte_t *);
@@ -509,27 +509,27 @@ chkau(hte_t *hte, int n, sym_t *def, sym @@ -509,27 +509,27 @@ chkau(hte_t *hte, int n, sym_t *def, sym
509 t1 = DOUBLE; 509 t1 = DOUBLE;
510 } else if (t1 == CHAR || t1 == SCHAR) { 510 } else if (t1 == CHAR || t1 == SCHAR) {
511 t1 = INT; 511 t1 = INT;
512 } else if (t1 == UCHAR) { 512 } else if (t1 == UCHAR) {
513 t1 = tflag ? UINT : INT; 513 t1 = tflag ? UINT : INT;
514 } else if (t1 == SHORT) { 514 } else if (t1 == SHORT) {
515 t1 = INT; 515 t1 = INT;
516 } else if (t1 == USHORT) { 516 } else if (t1 == USHORT) {
517 /* CONSTCOND */ 517 /* CONSTCOND */
518 t1 = INT_MAX < USHRT_MAX || tflag ? UINT : INT; 518 t1 = INT_MAX < USHRT_MAX || tflag ? UINT : INT;
519 } 519 }
520 } 520 }
521 521
522 if (styp(t1) == styp(t2)) { 522 if (signed_type(t1) == signed_type(t2)) {
523 523
524 /* 524 /*
525 * types differ only in signedness; get information 525 * types differ only in signedness; get information
526 * about arguments 526 * about arguments
527 */ 527 */
528 528
529 /* 529 /*
530 * treat a definition like a call with variable 530 * treat a definition like a call with variable
531 * arguments 531 * arguments
532 */ 532 */
533 ai1 = call1 != NULL ? call1->f_args : NULL; 533 ai1 = call1 != NULL ? call1->f_args : NULL;
534 534
535 /* 535 /*
@@ -891,27 +891,27 @@ scanflike(hte_t *hte, fcall_t *call, int @@ -891,27 +891,27 @@ scanflike(hte_t *hte, fcall_t *call, int
891 if ((t1 = tp->t_tspec) == PTR) 891 if ((t1 = tp->t_tspec) == PTR)
892 t2 = tp->t_subt->t_tspec; 892 t2 = tp->t_subt->t_tspec;
893 } 893 }
894 894
895 if (fc == 'd' || fc == 'i' || fc == 'n') { 895 if (fc == 'd' || fc == 'i' || fc == 'n') {
896 if (sz == LDOUBLE) 896 if (sz == LDOUBLE)
897 badfmt(hte, call); 897 badfmt(hte, call);
898 if (sz != SHORT && sz != LONG && sz != QUAD) 898 if (sz != SHORT && sz != LONG && sz != QUAD)
899 sz = INT; 899 sz = INT;
900 conv: 900 conv:
901 if (!noasgn) { 901 if (!noasgn) {
902 if (t1 != PTR) { 902 if (t1 != PTR) {
903 inconarg(hte, call, n); 903 inconarg(hte, call, n);
904 } else if (t2 != styp(sz)) { 904 } else if (t2 != signed_type(sz)) {
905 inconarg(hte, call, n); 905 inconarg(hte, call, n);
906 } else if (hflag && t2 != sz) { 906 } else if (hflag && t2 != sz) {
907 inconarg(hte, call, n); 907 inconarg(hte, call, n);
908 } else if (tp->t_subt->t_const) { 908 } else if (tp->t_subt->t_const) {
909 inconarg(hte, call, n); 909 inconarg(hte, call, n);
910 } 910 }
911 } 911 }
912 } else if (fc == 'o' || fc == 'u' || fc == 'x') { 912 } else if (fc == 'o' || fc == 'u' || fc == 'x') {
913 if (sz == LDOUBLE) 913 if (sz == LDOUBLE)
914 badfmt(hte, call); 914 badfmt(hte, call);
915 if (sz == SHORT) { 915 if (sz == SHORT) {
916 sz = USHORT; 916 sz = USHORT;
917 } else if (sz == LONG) { 917 } else if (sz == LONG) {
@@ -1232,27 +1232,27 @@ eqtype(type_t *tp1, type_t *tp2, int ign @@ -1232,27 +1232,27 @@ eqtype(type_t *tp1, type_t *tp2, int ign
1232 1232
1233 if (asgn && to == PTR) { 1233 if (asgn && to == PTR) {
1234 if (indir == 1 && (t == VOID || tp2->t_tspec == VOID)) 1234 if (indir == 1 && (t == VOID || tp2->t_tspec == VOID))
1235 return 1; 1235 return 1;
1236 } 1236 }
1237 1237
1238 if (t != tp2->t_tspec) { 1238 if (t != tp2->t_tspec) {
1239 /* 1239 /*
1240 * Give pointer to types which differ only in 1240 * Give pointer to types which differ only in
1241 * signedness a chance if not sflag and not hflag. 1241 * signedness a chance if not sflag and not hflag.
1242 */ 1242 */
1243 if (sflag || hflag || to != PTR) 1243 if (sflag || hflag || to != PTR)
1244 return 0; 1244 return 0;
1245 if (styp(t) != styp(tp2->t_tspec)) 1245 if (signed_type(t) != signed_type(tp2->t_tspec))
1246 return 0; 1246 return 0;
1247 } 1247 }
1248 1248
1249 if (tp1->t_isenum && tp2->t_isenum) { 1249 if (tp1->t_isenum && tp2->t_isenum) {
1250 if (tp1->t_istag && tp2->t_istag) { 1250 if (tp1->t_istag && tp2->t_istag) {
1251 return tp1->t_tag == tp2->t_tag; 1251 return tp1->t_tag == tp2->t_tag;
1252 } else if (tp1->t_istynam && tp2->t_istynam) { 1252 } else if (tp1->t_istynam && tp2->t_istynam) {
1253 return tp1->t_tynam == tp2->t_tynam; 1253 return tp1->t_tynam == tp2->t_tynam;
1254 } else if (tp1->t_isuniqpos && tp2->t_isuniqpos) { 1254 } else if (tp1->t_isuniqpos && tp2->t_isuniqpos) {
1255 return (tp1->t_uniqpos.p_line == 1255 return (tp1->t_uniqpos.p_line ==
1256 tp2->t_uniqpos.p_line && 1256 tp2->t_uniqpos.p_line &&
1257 tp1->t_uniqpos.p_file == 1257 tp1->t_uniqpos.p_file ==
1258 tp2->t_uniqpos.p_file && 1258 tp2->t_uniqpos.p_file &&