Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint lint: rename tspec macros



details:   https://anonhg.NetBSD.org/src/rev/7d7f0f3810c5
branches:  trunk
changeset: 948667:7d7f0f3810c5
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Dec 28 18:49:02 2020 +0000

description:
lint: rename tspec macros

diffstat:

 usr.bin/xlint/common/lint.h |   34 ++++----
 usr.bin/xlint/lint1/cgram.y |    6 +-
 usr.bin/xlint/lint1/decl.c  |    6 +-
 usr.bin/xlint/lint1/emit1.c |    6 +-
 usr.bin/xlint/lint1/func.c  |   22 ++--
 usr.bin/xlint/lint1/init.c  |   19 ++--
 usr.bin/xlint/lint1/scan.l  |    8 +-
 usr.bin/xlint/lint1/tree.c  |  187 ++++++++++++++++++++++++-------------------
 usr.bin/xlint/lint2/chk.c   |    9 +-
 9 files changed, 160 insertions(+), 137 deletions(-)

diffs (truncated from 1028 to 300 lines):

diff -r f8bec893463a -r 7d7f0f3810c5 usr.bin/xlint/common/lint.h
--- a/usr.bin/xlint/common/lint.h       Mon Dec 28 18:06:23 2020 +0000
+++ b/usr.bin/xlint/common/lint.h       Mon Dec 28 18:49:02 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lint.h,v 1.15 2020/12/28 18:06:23 rillig Exp $ */
+/*     $NetBSD: lint.h,v 1.16 2020/12/28 18:49:02 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -94,25 +94,25 @@
                                           if pflag is set */
        tspec_t tt_styp;                /* signed counterpart */
        tspec_t tt_utyp;                /* unsigned counterpart */
-       u_int   tt_isityp : 1;          /* 1 if integer type */
-       u_int   tt_isutyp : 1;          /* 1 if unsigned integer type */
-       u_int   tt_isftyp : 1;          /* 1 if floating point type */
-       u_int   tt_isatyp : 1;          /* 1 if arithmetic type */
-       u_int   tt_issclt : 1;          /* 1 if scalar type */
-       u_int   tt_isctyp : 1;          /* 1 if complex type */
+       u_int   tt_is_int : 1;          /* 1 if integer type */
+       u_int   tt_is_uint : 1;         /* 1 if unsigned integer type */
+       u_int   tt_is_float : 1;        /* 1 if floating point type */
+       u_int   tt_is_arith : 1;        /* 1 if arithmetic type */
+       u_int   tt_is_scalar : 1;       /* 1 if scalar type */
+       u_int   tt_is_complex : 1;      /* 1 if complex type */
        const char *tt_name;            /* name of the type */
 } ttab_t;
 
-#define size(t)                (ttab[t].tt_sz)
-#define psize(t)       (ttab[t].tt_psz)
-#define styp(t)                (ttab[t].tt_styp)
-#define utyp(t)                (ttab[t].tt_utyp)
-#define isityp(t)      (ttab[t].tt_isityp)
-#define isutyp(t)      (ttab[t].tt_isutyp)
-#define isftyp(t)      (ttab[t].tt_isftyp)
-#define isatyp(t)      (ttab[t].tt_isatyp)
-#define isctyp(t)      (ttab[t].tt_isctyp)
-#define issclt(t)      (ttab[t].tt_issclt)
+#define size(t)                        (ttab[t].tt_sz)
+#define psize(t)               (ttab[t].tt_psz)
+#define styp(t)                        (ttab[t].tt_styp)
+#define utyp(t)                        (ttab[t].tt_utyp)
+#define tspec_is_int(t)                (ttab[t].tt_is_int)
+#define tspec_is_uint(t)       (ttab[t].tt_is_uint)
+#define tspec_is_float(t)      (ttab[t].tt_is_float)
+#define tspec_is_arith(t)      (ttab[t].tt_is_arith)
+#define tspec_is_complex(t)    (ttab[t].tt_is_complex)
+#define tspec_is_scalar(t)     (ttab[t].tt_is_scalar)
 
 extern ttab_t  ttab[];
 
diff -r f8bec893463a -r 7d7f0f3810c5 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Mon Dec 28 18:06:23 2020 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Mon Dec 28 18:49:02 2020 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.106 2020/12/04 17:56:04 christos Exp $ */
+/* $NetBSD: cgram.y,v 1.107 2020/12/28 18:51:18 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.106 2020/12/04 17:56:04 christos Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.107 2020/12/28 18:51:18 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -2080,7 +2080,7 @@
                error(55);
        } else {
                i = (int)v->v_quad;
-               if (isutyp(t)) {
+               if (tspec_is_uint(t)) {
                        if (uq_gt((uint64_t)v->v_quad,
                                  (uint64_t)TARG_INT_MAX)) {
                                /* integral constant too large */
diff -r f8bec893463a -r 7d7f0f3810c5 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Mon Dec 28 18:06:23 2020 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Mon Dec 28 18:49:02 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.71 2020/06/02 21:10:07 christos Exp $ */
+/* $NetBSD: decl.c,v 1.72 2020/12/28 18:49:02 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.71 2020/06/02 21:10:07 christos Exp $");
+__RCSID("$NetBSD: decl.c,v 1.72 2020/12/28 18:49:02 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -1142,7 +1142,7 @@
                         * Integer types not dealt with above are
                         * okay only if BITFIELDTYPE is in effect.
                         */
-                       if (bitfieldtype_ok == 0 || isityp(t) == 0) {
+                       if (bitfieldtype_ok == 0 || tspec_is_int(t) == 0) {
                                /* illegal bit-field type */
                                warning(35);
                                sz = tp->t_flen;
diff -r f8bec893463a -r 7d7f0f3810c5 usr.bin/xlint/lint1/emit1.c
--- a/usr.bin/xlint/lint1/emit1.c       Mon Dec 28 18:06:23 2020 +0000
+++ b/usr.bin/xlint/lint1/emit1.c       Mon Dec 28 18:49:02 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: emit1.c,v 1.21 2020/12/28 12:52:45 rillig Exp $ */
+/* $NetBSD: emit1.c,v 1.22 2020/12/28 18:49:02 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: emit1.c,v 1.21 2020/12/28 12:52:45 rillig Exp $");
+__RCSID("$NetBSD: emit1.c,v 1.22 2020/12/28 18:49:02 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -442,7 +442,7 @@
                        continue;
                arg = arg->tn_left;
                if (arg->tn_op == CON) {
-                       if (isityp(t = arg->tn_type->t_tspec)) {
+                       if (tspec_is_int(t = arg->tn_type->t_tspec)) {
                                /*
                                 * XXX it would probably be better to
                                 * explicitly test the sign
diff -r f8bec893463a -r 7d7f0f3810c5 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c        Mon Dec 28 18:06:23 2020 +0000
+++ b/usr.bin/xlint/lint1/func.c        Mon Dec 28 18:49:02 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: func.c,v 1.26 2016/08/19 10:58:15 christos Exp $       */
+/*     $NetBSD: func.c,v 1.27 2020/12/28 18:49:02 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.26 2016/08/19 10:58:15 christos Exp $");
+__RCSID("$NetBSD: func.c,v 1.27 2020/12/28 18:49:02 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -443,7 +443,7 @@
                        /* non-constant case expression */
                        error(197);
                        tn = NULL;
-               } else if (tn != NULL && !isityp(tn->tn_type->t_tspec)) {
+               } else if (tn != NULL && !tspec_is_int(tn->tn_type->t_tspec)) {
                        /* non-integral case expression */
                        error(198);
                        tn = NULL;
@@ -482,7 +482,7 @@
                                if (cl->cl_val.v_quad == nv.v_quad)
                                        break;
                        }
-                       if (cl != NULL && isutyp(nv.v_tspec)) {
+                       if (cl != NULL && tspec_is_uint(nv.v_tspec)) {
                                /* duplicate case in switch, %lu */
                                error(200, (u_long)nv.v_quad);
                        } else if (cl != NULL) {
@@ -583,7 +583,7 @@
                tn = cconv(tn);
        if (tn != NULL)
                tn = promote(NOOP, 0, tn);
-       if (tn != NULL && !isityp(tn->tn_type->t_tspec)) {
+       if (tn != NULL && !tspec_is_int(tn->tn_type->t_tspec)) {
                /* switch expression must have integral type */
                error(205);
                tn = NULL;
@@ -693,7 +693,7 @@
                tn = cconv(tn);
        if (tn != NULL)
                tn = promote(NOOP, 0, tn);
-       if (tn != NULL && !issclt(tn->tn_type->t_tspec)) {
+       if (tn != NULL && !tspec_is_scalar(tn->tn_type->t_tspec)) {
                /* controlling expressions must have scalar type */
                error(204);
                tn = NULL;
@@ -702,7 +702,7 @@
        pushctrl(T_WHILE);
        cstk->c_loop = 1;
        if (tn != NULL && tn->tn_op == CON) {
-               if (isityp(tn->tn_type->t_tspec)) {
+               if (tspec_is_int(tn->tn_type->t_tspec)) {
                        cstk->c_infinite = tn->tn_val->v_quad != 0;
                } else {
                        cstk->c_infinite = tn->tn_val->v_ldbl != 0.0;
@@ -766,14 +766,14 @@
                tn = cconv(tn);
        if (tn != NULL)
                tn = promote(NOOP, 0, tn);
-       if (tn != NULL && !issclt(tn->tn_type->t_tspec)) {
+       if (tn != NULL && !tspec_is_scalar(tn->tn_type->t_tspec)) {
                /* controlling expressions must have scalar type */
                error(204);
                tn = NULL;
        }
 
        if (tn != NULL && tn->tn_op == CON) {
-               if (isityp(tn->tn_type->t_tspec)) {
+               if (tspec_is_int(tn->tn_type->t_tspec)) {
                        cstk->c_infinite = tn->tn_val->v_quad != 0;
                } else {
                        cstk->c_infinite = tn->tn_val->v_ldbl != 0.0;
@@ -831,7 +831,7 @@
                tn2 = cconv(tn2);
        if (tn2 != NULL)
                tn2 = promote(NOOP, 0, tn2);
-       if (tn2 != NULL && !issclt(tn2->tn_type->t_tspec)) {
+       if (tn2 != NULL && !tspec_is_scalar(tn2->tn_type->t_tspec)) {
                /* controlling expressions must have scalar type */
                error(204);
                tn2 = NULL;
@@ -842,7 +842,7 @@
        if (tn2 == NULL) {
                cstk->c_infinite = 1;
        } else if (tn2->tn_op == CON) {
-               if (isityp(tn2->tn_type->t_tspec)) {
+               if (tspec_is_int(tn2->tn_type->t_tspec)) {
                        cstk->c_infinite = tn2->tn_val->v_quad != 0;
                } else {
                        cstk->c_infinite = tn2->tn_val->v_ldbl != 0.0;
diff -r f8bec893463a -r 7d7f0f3810c5 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Mon Dec 28 18:06:23 2020 +0000
+++ b/usr.bin/xlint/lint1/init.c        Mon Dec 28 18:49:02 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.28 2020/12/28 12:52:45 rillig Exp $ */
+/*     $NetBSD: init.c,v 1.29 2020/12/28 18:49:02 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.28 2020/12/28 12:52:45 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.29 2020/12/28 18:49:02 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -281,7 +281,7 @@
 
        if (istk->i_cnt <= 0)
                LERROR("pushinit()");
-       if (istk->i_type != NULL && issclt(istk->i_type->t_tspec))
+       if (istk->i_type != NULL && tspec_is_scalar(istk->i_type->t_tspec))
                LERROR("pushinit()");
 
        initstk = xcalloc(1, sizeof (istk_t));
@@ -431,7 +431,7 @@
        DPRINTF(("%s(%d)\n", __func__, brace));
        if (!brace) {
                if (initstk->i_type == NULL &&
-                   !issclt(initstk->i_subt->t_tspec)) {
+                   !tspec_is_scalar(initstk->i_subt->t_tspec)) {
                        /* {}-enclosed initializer required */
                        error(181);
                }
@@ -442,13 +442,14 @@
                if (!initerr)
                        testinit();
                while (!initerr && (initstk->i_type == NULL ||
-                                   !issclt(initstk->i_type->t_tspec))) {
+                                   !tspec_is_scalar(
+                                       initstk->i_type->t_tspec))) {
                        if (!initerr)
                                pushinit();
                }
        } else {
                if (initstk->i_type != NULL &&
-                   issclt(initstk->i_type->t_tspec)) {
+                   tspec_is_scalar(initstk->i_type->t_tspec)) {
                        /* invalid initializer */
                        error(176, tyname(buf, sizeof(buf), initstk->i_type));
                        initerr = 1;
@@ -477,7 +478,7 @@
 
        if ((initsym->s_scl == AUTO || initsym->s_scl == REG) &&
            initstk->i_nxt == NULL) {
-               if (tflag && !issclt(initstk->i_subt->t_tspec))
+               if (tflag && !tspec_is_scalar(initstk->i_subt->t_tspec))
                        /* no automatic aggregate initialization in trad. C*/
                        warning(188);
        }
@@ -572,7 +573,7 @@
        lt = ln->tn_type->t_tspec;
        rt = tn->tn_type->t_tspec;
 
-       if (!issclt(lt))
+       if (!tspec_is_scalar(lt))
                LERROR("mkinit()");



Home | Main Index | Thread Index | Old Index