Module Name: src Committed By: rillig Date: Thu Jun 29 10:31:33 UTC 2023
Modified Files: src/usr.bin/xlint/common: externs.h inittyp.c lint.h src/usr.bin/xlint/lint1: decl.c emit1.c src/usr.bin/xlint/lint2: emit2.c Log Message: lint: clean up initialization of type properties No functional change. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/usr.bin/xlint/common/externs.h cvs rdiff -u -r1.35 -r1.36 src/usr.bin/xlint/common/inittyp.c cvs rdiff -u -r1.36 -r1.37 src/usr.bin/xlint/common/lint.h cvs rdiff -u -r1.320 -r1.321 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.69 -r1.70 src/usr.bin/xlint/lint1/emit1.c cvs rdiff -u -r1.31 -r1.32 src/usr.bin/xlint/lint2/emit2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xlint/common/externs.h diff -u src/usr.bin/xlint/common/externs.h:1.26 src/usr.bin/xlint/common/externs.h:1.27 --- src/usr.bin/xlint/common/externs.h:1.26 Sat Jun 24 07:15:08 2023 +++ src/usr.bin/xlint/common/externs.h Thu Jun 29 10:31:32 2023 @@ -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 *); Index: src/usr.bin/xlint/common/inittyp.c diff -u src/usr.bin/xlint/common/inittyp.c:1.35 src/usr.bin/xlint/common/inittyp.c:1.36 --- src/usr.bin/xlint/common/inittyp.c:1.35 Fri Jun 9 13:03:49 2023 +++ src/usr.bin/xlint/common/inittyp.c Thu Jun 29 10:31:32 2023 @@ -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 Index: src/usr.bin/xlint/common/lint.h diff -u src/usr.bin/xlint/common/lint.h:1.36 src/usr.bin/xlint/common/lint.h:1.37 --- src/usr.bin/xlint/common/lint.h:1.36 Mon May 22 12:55:04 2023 +++ src/usr.bin/xlint/common/lint.h Thu Jun 29 10:31:32 2023 @@ -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; Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.320 src/usr.bin/xlint/lint1/decl.c:1.321 --- src/usr.bin/xlint/lint1/decl.c:1.320 Thu Jun 29 09:58:36 2023 +++ src/usr.bin/xlint/lint1/decl.c Thu Jun 29 10:31:33 2023 @@ -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(); + 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; + } - /* - * 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; /* 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; } /* Index: src/usr.bin/xlint/lint1/emit1.c diff -u src/usr.bin/xlint/lint1/emit1.c:1.69 src/usr.bin/xlint/lint1/emit1.c:1.70 --- src/usr.bin/xlint/lint1/emit1.c:1.69 Sat Jun 24 20:50:54 2023 +++ src/usr.bin/xlint/lint1/emit1.c Thu Jun 29 10:31:33 2023 @@ -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; Index: src/usr.bin/xlint/lint2/emit2.c diff -u src/usr.bin/xlint/lint2/emit2.c:1.31 src/usr.bin/xlint/lint2/emit2.c:1.32 --- src/usr.bin/xlint/lint2/emit2.c:1.31 Fri Jun 9 13:03:49 2023 +++ src/usr.bin/xlint/lint2/emit2.c Thu Jun 29 10:31:33 2023 @@ -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) {