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: clean up initialization of type properties
details: https://anonhg.NetBSD.org/src/rev/66143d559fb4
branches: trunk
changeset: 376698:66143d559fb4
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Jun 29 10:31:32 2023 +0000
description:
lint: clean up initialization of type properties
No functional change.
diffstat:
usr.bin/xlint/common/externs.h | 7 +----
usr.bin/xlint/common/inittyp.c | 38 +++++++-----------------------
usr.bin/xlint/common/lint.h | 12 ++++----
usr.bin/xlint/lint1/decl.c | 52 ++++++++++++-----------------------------
usr.bin/xlint/lint1/emit1.c | 12 ++++----
usr.bin/xlint/lint2/emit2.c | 12 ++++----
6 files changed, 44 insertions(+), 89 deletions(-)
diffs (261 lines):
diff -r 23306825c9d1 -r 66143d559fb4 usr.bin/xlint/common/externs.h
--- a/usr.bin/xlint/common/externs.h Thu Jun 29 09:58:36 2023 +0000
+++ b/usr.bin/xlint/common/externs.h Thu Jun 29 10:31:32 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: externs.h,v 1.26 2023/06/24 07:15:08 rillig Exp $ */
+/* $NetBSD: externs.h,v 1.27 2023/06/29 10:31:32 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -32,11 +32,6 @@
*/
/*
- * inittyp.c
- */
-void inittyp(void);
-
-/*
* tyname.c
*/
const char *type_name(const type_t *);
diff -r 23306825c9d1 -r 66143d559fb4 usr.bin/xlint/common/inittyp.c
--- a/usr.bin/xlint/common/inittyp.c Thu Jun 29 09:58:36 2023 +0000
+++ b/usr.bin/xlint/common/inittyp.c Thu Jun 29 10:31:32 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: inittyp.c,v 1.35 2023/06/09 13:03:49 rillig Exp $ */
+/* $NetBSD: inittyp.c,v 1.36 2023/06/29 10:31:32 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: inittyp.c,v 1.35 2023/06/09 13:03:49 rillig Exp $");
+__RCSID("$NetBSD: inittyp.c,v 1.36 2023/06/29 10:31:32 rillig Exp $");
#endif
#if defined(IS_LINT1)
@@ -103,13 +103,6 @@ ttab_t ttab[NTSPEC] = {
typeinfo("float", FLOAT, FLOAT, FLOAT_SIZE, 32, 'f'),
typeinfo("double", DOUBLE, DOUBLE, DOUBLE_SIZE, 64, 'f'),
typeinfo("long double", LDOUBLE, LDOUBLE, LDOUBLE_SIZE, 80, 'f'),
- typeinfo("void", VOID, VOID, 0, 0, ' '),
- typeinfo("struct", STRUCT, STRUCT, 0, 0, ' '),
- typeinfo("union", UNION, UNION, 0, 0, ' '),
- typeinfo("enum", ENUM, ENUM, ENUM_SIZE, 24, 's'),
- typeinfo("pointer", PTR, PTR, PTR_SIZE, 32, 'p'),
- typeinfo("array", ARRAY, ARRAY, 0, 0, ' '),
- typeinfo("function", FUNC, FUNC, 0, 0, ' '),
#ifdef DEBUG
typeinfo("_Complex", NO_TSPEC, NO_TSPEC, 0, 0, ' '),
#else
@@ -121,25 +114,12 @@ ttab_t ttab[NTSPEC] = {
DOUBLE_SIZE * 2, 64 * 2, 'c'),
typeinfo("long double _Complex", LCOMPLEX, LCOMPLEX,
LDOUBLE_SIZE * 2, 80 * 2, 'c'),
+ typeinfo("void", VOID, VOID, 0, 0, ' '),
+ typeinfo("struct", STRUCT, STRUCT, 0, 0, ' '),
+ typeinfo("union", UNION, UNION, 0, 0, ' '),
+ typeinfo("enum", ENUM, ENUM, ENUM_SIZE, 24, 's'),
+ typeinfo("pointer", PTR, PTR, PTR_SIZE, 32, 'p'),
+ typeinfo("array", ARRAY, ARRAY, 0, 0, ' '),
+ typeinfo("function", FUNC, FUNC, 0, 0, ' '),
};
#undef typeinfo
-
-#ifdef IS_LINT1
-void
-inittyp(void)
-{
- size_t i;
-
- if (!pflag) {
- for (i = 0; i < NTSPEC; i++)
- ttab[i].tt_portable_size_in_bits =
- ttab[i].tt_size_in_bits;
- }
-
- if (Tflag) {
- ttab[BOOL].tt_is_integer = false;
- ttab[BOOL].tt_is_uinteger = false;
- ttab[BOOL].tt_is_arithmetic = false;
- }
-}
-#endif
diff -r 23306825c9d1 -r 66143d559fb4 usr.bin/xlint/common/lint.h
--- a/usr.bin/xlint/common/lint.h Thu Jun 29 09:58:36 2023 +0000
+++ b/usr.bin/xlint/common/lint.h Thu Jun 29 10:31:32 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint.h,v 1.36 2023/05/22 12:55:04 rillig Exp $ */
+/* $NetBSD: lint.h,v 1.37 2023/06/29 10:31:32 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -73,6 +73,10 @@ typedef enum {
FLOAT, /* float */
DOUBLE, /* double or, with tflag, long float */
LDOUBLE, /* long double */
+ COMPLEX, /* keyword "_Complex", only used in the parser */
+ FCOMPLEX, /* float _Complex */
+ DCOMPLEX, /* double _Complex */
+ LCOMPLEX, /* long double _Complex */
VOID, /* void */
STRUCT, /* structure tag */
UNION, /* union tag */
@@ -80,11 +84,7 @@ typedef enum {
PTR, /* pointer */
ARRAY, /* array */
FUNC, /* function */
- COMPLEX, /* keyword "_Complex", only used in the parser */
- FCOMPLEX, /* float _Complex */
- DCOMPLEX, /* double _Complex */
- LCOMPLEX /* long double _Complex */
-#define NTSPEC (LCOMPLEX + 1)
+#define NTSPEC ((int)FUNC + 1)
} tspec_t;
diff -r 23306825c9d1 -r 66143d559fb4 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c Thu Jun 29 09:58:36 2023 +0000
+++ b/usr.bin/xlint/lint1/decl.c Thu Jun 29 10:31:32 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.320 2023/06/29 09:58:36 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.321 2023/06/29 10:31:33 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: decl.c,v 1.320 2023/06/29 09:58:36 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.321 2023/06/29 10:31:33 rillig Exp $");
#endif
#include <sys/param.h>
@@ -97,41 +97,21 @@ initdecl(void)
dcs->d_kind = DK_EXTERN;
dcs->d_ldlsym = &dcs->d_dlsyms;
- /* type information and classification */
- inittyp();
-
- /*
- * The following two are not really types. They are only used by the
- * parser to handle the keywords "signed" and "unsigned".
- */
- typetab[SIGNED].t_tspec = SIGNED;
- typetab[UNSIGN].t_tspec = UNSIGN;
-
- typetab[BOOL].t_tspec = BOOL;
- typetab[CHAR].t_tspec = CHAR;
- typetab[SCHAR].t_tspec = SCHAR;
- typetab[UCHAR].t_tspec = UCHAR;
- typetab[SHORT].t_tspec = SHORT;
- typetab[USHORT].t_tspec = USHORT;
- typetab[INT].t_tspec = INT;
- typetab[UINT].t_tspec = UINT;
- typetab[LONG].t_tspec = LONG;
- typetab[ULONG].t_tspec = ULONG;
- typetab[QUAD].t_tspec = QUAD;
- typetab[UQUAD].t_tspec = UQUAD;
-#ifdef INT128_SIZE
- typetab[INT128].t_tspec = INT128;
- typetab[UINT128].t_tspec = UINT128;
-#endif
- typetab[FLOAT].t_tspec = FLOAT;
- typetab[DOUBLE].t_tspec = DOUBLE;
- typetab[LDOUBLE].t_tspec = LDOUBLE;
- typetab[VOID].t_tspec = VOID;
+ if (!pflag) {
+ for (size_t i = 0; i < NTSPEC; i++)
+ ttab[i].tt_portable_size_in_bits =
+ ttab[i].tt_size_in_bits;
+ }
+
+ if (Tflag) {
+ ttab[BOOL].tt_is_integer = false;
+ ttab[BOOL].tt_is_uinteger = false;
+ ttab[BOOL].tt_is_arithmetic = false;
+ }
+
/* struct, union, enum, ptr, array and func are not shared. */
- typetab[COMPLEX].t_tspec = COMPLEX;
- typetab[FCOMPLEX].t_tspec = FCOMPLEX;
- typetab[DCOMPLEX].t_tspec = DCOMPLEX;
- typetab[LCOMPLEX].t_tspec = LCOMPLEX;
+ for (int i = (int)SIGNED; i < (int)STRUCT; i++)
+ typetab[i].t_tspec = (tspec_t)i;
}
/*
diff -r 23306825c9d1 -r 66143d559fb4 usr.bin/xlint/lint1/emit1.c
--- a/usr.bin/xlint/lint1/emit1.c Thu Jun 29 09:58:36 2023 +0000
+++ b/usr.bin/xlint/lint1/emit1.c Thu Jun 29 10:31:32 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: emit1.c,v 1.69 2023/06/24 20:50:54 rillig Exp $ */
+/* $NetBSD: emit1.c,v 1.70 2023/06/29 10:31:33 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: emit1.c,v 1.69 2023/06/24 20:50:54 rillig Exp $");
+__RCSID("$NetBSD: emit1.c,v 1.70 2023/06/29 10:31:33 rillig Exp $");
#endif
#include "lint1.h"
@@ -94,11 +94,11 @@ outtype(const type_t *tp)
{
/* Available letters: ------GH--K-MNO--R--U-W-YZ */
#ifdef INT128_SIZE
- static const char tt[NTSPEC] = "???BCCCSSIILLQQJJDDDVTTTPAF?XXX";
- static const char ss[NTSPEC] = "??? su u u u u us l sue ?s l";
+ static const char tt[NTSPEC] = "???BCCCSSIILLQQJJDDD?XXXVTTTPAF";
+ static const char ss[NTSPEC] = "??? su u u u u us l?s l sue ";
#else
- static const char tt[NTSPEC] = "???BCCCSSIILLQQDDDVTTTPAF?XXX";
- static const char ss[NTSPEC] = "??? su u u u us l sue ?s l";
+ static const char tt[NTSPEC] = "???BCCCSSIILLQQDDD?XXXVTTTPAF";
+ static const char ss[NTSPEC] = "??? su u u u us l?s l sue ";
#endif
int na;
sym_t *arg;
diff -r 23306825c9d1 -r 66143d559fb4 usr.bin/xlint/lint2/emit2.c
--- a/usr.bin/xlint/lint2/emit2.c Thu Jun 29 09:58:36 2023 +0000
+++ b/usr.bin/xlint/lint2/emit2.c Thu Jun 29 10:31:32 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: emit2.c,v 1.31 2023/06/09 13:03:49 rillig Exp $ */
+/* $NetBSD: emit2.c,v 1.32 2023/06/29 10:31:33 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -34,7 +34,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: emit2.c,v 1.31 2023/06/09 13:03:49 rillig Exp $");
+__RCSID("$NetBSD: emit2.c,v 1.32 2023/06/29 10:31:33 rillig Exp $");
#endif
#include "lint2.h"
@@ -51,11 +51,11 @@ static void
outtype(type_t *tp)
{
#ifdef INT128_SIZE
- static const char tt[NTSPEC] = "???BCCCSSIILLQQJJDDDVTTTPAF?XXX";
- static const char ss[NTSPEC] = "??? su u u u u us l sue ?s l";
+ static const char tt[NTSPEC] = "???BCCCSSIILLQQJJDDD?XXXVTTTPAF";
+ static const char ss[NTSPEC] = "??? su u u u u us l?s l sue ";
#else
- static const char tt[NTSPEC] = "???BCCCSSIILLQQDDDVTTTPAF?XXX";
- static const char ss[NTSPEC] = "??? su u u u us l sue ?s l";
+ static const char tt[NTSPEC] = "???BCCCSSIILLQQDDD?XXXVTTTPAF";
+ static const char ss[NTSPEC] = "??? su u u u us l?s l sue ";
#endif
while (tp != NULL) {
Home |
Main Index |
Thread Index |
Old Index