lint: un-abbreviate s_field, s_keyw and s_xsym

This commit is contained in:
rillig 2020-12-30 11:04:48 +00:00
parent a2826784dd
commit eb502cf640
5 changed files with 30 additions and 32 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: decl.c,v 1.82 2020/12/30 10:49:10 rillig Exp $ */
/* $NetBSD: decl.c,v 1.83 2020/12/30 11:04:48 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.82 2020/12/30 10:49:10 rillig Exp $");
__RCSID("$NetBSD: decl.c,v 1.83 2020/12/30 11:04:48 rillig Exp $");
#endif
#include <sys/param.h>
@ -1106,10 +1106,8 @@ declarator_1_struct_union(sym_t *dsym)
t = (tp = dsym->s_type)->t_tspec;
if (dsym->s_field) {
if (dsym->s_bitfield) {
/*
* bit field
*
* only unsigned and signed int are portable bit-field types
*(at least in ANSI C, in traditional C only unsigned int)
*/
@ -1163,7 +1161,7 @@ declarator_1_struct_union(sym_t *dsym)
/* illegal use of bit-field */
error(41);
dsym->s_type->t_isfield = 0;
dsym->s_field = 0;
dsym->s_bitfield = 0;
}
} else if (t == FUNC) {
/* function illegal in structure or union */
@ -1187,7 +1185,7 @@ declarator_1_struct_union(sym_t *dsym)
o = dcs->d_offset;
dcs->d_offset = 0;
}
if (dsym->s_field) {
if (dsym->s_bitfield) {
align(getbound(tp), tp->t_flen);
dsym->s_value.v_quad = (dcs->d_offset / size(t)) * size(t);
tp->t_foffs = dcs->d_offset - (int)dsym->s_value.v_quad;
@ -1254,7 +1252,7 @@ bitfield(sym_t *dsym, int len)
dsym->s_type = duptyp(dsym->s_type);
dsym->s_type->t_isfield = 1;
dsym->s_type->t_flen = len;
dsym->s_field = 1;
dsym->s_bitfield = 1;
return dsym;
}
@ -2610,10 +2608,10 @@ decl1loc(sym_t *dsym, int initflg)
* XXX if the static variable at level 0 is only defined
* later, checking will be possible.
*/
if (dsym->s_xsym == NULL) {
if (dsym->s_ext_sym == NULL) {
outsym(dsym, EXTERN, dsym->s_def);
} else {
outsym(dsym, dsym->s_xsym->s_scl, dsym->s_def);
outsym(dsym, dsym->s_ext_sym->s_scl, dsym->s_def);
}
}
@ -2746,7 +2744,7 @@ ledecl(sym_t *dsym)
* Remember the external symbol so we can update usage
* information at the end of the block.
*/
dsym->s_xsym = esym;
dsym->s_ext_sym = esym;
}
}
@ -3030,7 +3028,7 @@ check_variable_usage(int novar, sym_t *sym)
* because symbols at level 0 only used in sizeof() are
* considered to not be used.
*/
if ((xsym = sym->s_xsym) != NULL) {
if ((xsym = sym->s_ext_sym) != NULL) {
if (sym->s_used && !xsym->s_used) {
xsym->s_used = 1;
STRUCT_ASSIGN(xsym->s_upos, sym->s_upos);

View File

@ -1,4 +1,4 @@
/* $NetBSD: init.c,v 1.47 2020/12/30 10:56:51 rillig Exp $ */
/* $NetBSD: init.c,v 1.48 2020/12/30 11:04:48 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.47 2020/12/30 10:56:51 rillig Exp $");
__RCSID("$NetBSD: init.c,v 1.48 2020/12/30 11:04:48 rillig Exp $");
#endif
#include <ctype.h>
@ -182,7 +182,7 @@ initstack_pop_item(void)
for (m = istk->i_type->t_str->memb; m != NULL; m = m->s_next) {
DPRINTF(("%s: pop lhs.name=%s rhs.name=%s\n", __func__,
m->s_name, namedmem->n_name));
if (m->s_field && m->s_name == unnamed)
if (m->s_bitfield && m->s_name == unnamed)
continue;
if (strcmp(m->s_name, namedmem->n_name) == 0) {
istk->i_subt = m->s_type;
@ -207,7 +207,7 @@ initstack_pop_item(void)
m = istk->i_mem = istk->i_mem->s_next;
lint_assert(m != NULL);
DPRINTF(("%s: pop %s\n", __func__, m->s_name));
} while (m->s_field && m->s_name == unnamed);
} while (m->s_bitfield && m->s_name == unnamed);
istk->i_subt = m->s_type;
}
}
@ -327,7 +327,7 @@ again:
tyname(buf, sizeof(buf), istk->i_type),
namedmem ? namedmem->n_name : "*none*", istk->i_namedmem));
for (m = istk->i_type->t_str->memb; m != NULL; m = m->s_next) {
if (m->s_field && m->s_name == unnamed)
if (m->s_bitfield && m->s_name == unnamed)
continue;
if (namedmem != NULL) {
DPRINTF(("%s: named lhs.member=%s, rhs.member=%s\n",

View File

@ -1,4 +1,4 @@
/* $NetBSD: lint1.h,v 1.42 2020/12/30 10:56:51 rillig Exp $ */
/* $NetBSD: lint1.h,v 1.43 2020/12/30 11:04:48 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@ -218,15 +218,15 @@ typedef enum {
typedef struct sym {
const char *s_name;
const char *s_rename; /* renamed symbol's given name */
pos_t s_dpos; /* position of last (prototype)definition,
pos_t s_dpos; /* position of last (prototype) definition,
prototype declaration, no-prototype-def.,
tentative definition or declaration,
in this order */
pos_t s_spos; /* position of first initialisation */
pos_t s_upos; /* position of first use */
symt_t s_kind; /* type of symbol */
void *s_keyw; /* keyword */
u_int s_field : 1; /* bit-field */
void *s_keyword;
u_int s_bitfield : 1;
u_int s_set : 1; /* variable set, label defined */
u_int s_used : 1; /* variable/label used */
u_int s_arg : 1; /* symbol is function argument */
@ -236,7 +236,7 @@ typedef struct sym {
u_int s_rimpl : 1; /* return value of function implicit decl. */
u_int s_osdef : 1; /* symbol stems from old style function def. */
u_int s_inline : 1; /* true if this is an inline function */
struct sym *s_xsym; /* for local declared external symbols pointer
struct sym *s_ext_sym; /* for local declared external symbols pointer
to external symbol with same name */
def_t s_def; /* declared, tentative defined, defined */
scl_t s_scl; /* storage class */

View File

@ -1,5 +1,5 @@
%{
/* $NetBSD: scan.l,v 1.102 2020/12/30 10:56:51 rillig Exp $ */
/* $NetBSD: scan.l,v 1.103 2020/12/30 11:04:48 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: scan.l,v 1.102 2020/12/30 10:56:51 rillig Exp $");
__RCSID("$NetBSD: scan.l,v 1.103 2020/12/30 11:04:48 rillig Exp $");
#endif
#include <ctype.h>
@ -358,7 +358,7 @@ add_keyword(struct kwtab *kw, int deco)
sym = getblk(sizeof (sym_t));
sym->s_name = name;
sym->s_keyw = kw;
sym->s_keyword = kw;
sym->s_value.v_quad = kw->kw_token;
if (kw->kw_token == T_TYPE || kw->kw_token == T_SOU) {
sym->s_tspec = kw->kw_tspec;
@ -497,7 +497,7 @@ name(void)
sb->sb_name = yytext;
sb->sb_len = yyleng;
sb->sb_hash = hash(yytext);
if ((sym = search(sb)) != NULL && sym->s_keyw) {
if ((sym = search(sb)) != NULL && sym->s_keyword) {
freesb(sb);
return keyw(sym);
}
@ -529,8 +529,8 @@ search(sbuf_t *sb)
for (sym = symtab[sb->sb_hash]; sym != NULL; sym = sym->s_link) {
if (strcmp(sym->s_name, sb->sb_name) == 0) {
if (sym->s_keyw) {
struct kwtab *kw = sym->s_keyw;
if (sym->s_keyword) {
struct kwtab *kw = sym->s_keyword;
if (!kw->kw_attr || attron)
return sym;
} else if (!attron && sym->s_kind == symtyp)

View File

@ -1,4 +1,4 @@
/* $NetBSD: tree.c,v 1.104 2020/12/30 10:56:51 rillig Exp $ */
/* $NetBSD: tree.c,v 1.105 2020/12/30 11:04:48 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
__RCSID("$NetBSD: tree.c,v 1.104 2020/12/30 10:56:51 rillig Exp $");
__RCSID("$NetBSD: tree.c,v 1.105 2020/12/30 11:04:48 rillig Exp $");
#endif
#include <float.h>
@ -384,11 +384,11 @@ struct_or_union_member(tnode_t *tn, op_t op, sym_t *msym)
eq = eqtype(csym->s_type, sym->s_type, 0, 0, &w) && !w;
if (!eq)
break;
if (csym->s_field != sym->s_field) {
if (csym->s_bitfield != sym->s_bitfield) {
eq = 0;
break;
}
if (csym->s_field) {
if (csym->s_bitfield) {
type_t *tp1, *tp2;
tp1 = csym->s_type;