Module Name: src
Committed By: rillig
Date: Thu Jun 29 22:52:44 UTC 2023
Modified Files:
src/usr.bin/xlint/lint1: cgram.y debug.c decl.c func.c lex.c lint1.h
Log Message:
lint: clean up member names of declaration levels
No functional change outside debug mode.
To generate a diff of this commit:
cvs rdiff -u -r1.438 -r1.439 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/xlint/lint1/debug.c
cvs rdiff -u -r1.322 -r1.323 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.158 -r1.159 src/usr.bin/xlint/lint1/func.c
cvs rdiff -u -r1.161 -r1.162 src/usr.bin/xlint/lint1/lex.c
cvs rdiff -u -r1.169 -r1.170 src/usr.bin/xlint/lint1/lint1.h
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/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.438 src/usr.bin/xlint/lint1/cgram.y:1.439
--- src/usr.bin/xlint/lint1/cgram.y:1.438 Thu Jun 29 09:58:36 2023
+++ src/usr.bin/xlint/lint1/cgram.y Thu Jun 29 22:52:44 2023
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.438 2023/06/29 09:58:36 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.439 2023/06/29 22:52:44 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: cgram.y,v 1.438 2023/06/29 09:58:36 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.439 2023/06/29 22:52:44 rillig Exp $");
#endif
#include <limits.h>
@@ -886,12 +886,12 @@ struct_or_union_specifier: /* C99 6.7.2.
$$ = make_tag_type($2, $1, false, yychar == T_SEMI);
}
| struct_or_union identifier_sym {
- dcs->d_tagtyp = make_tag_type($2, $1, true, false);
+ dcs->d_tag_type = make_tag_type($2, $1, true, false);
} braced_struct_declaration_list {
$$ = complete_struct_or_union($4);
}
| struct_or_union {
- dcs->d_tagtyp = make_tag_type(NULL, $1, true, false);
+ dcs->d_tag_type = make_tag_type(NULL, $1, true, false);
} braced_struct_declaration_list {
$$ = complete_struct_or_union($3);
}
@@ -1038,12 +1038,12 @@ enum_specifier: /* C99 6.7.2.2 */
$$ = make_tag_type($3, ENUM, false, false);
}
| enum gcc_attribute_specifier_list_opt identifier_sym {
- dcs->d_tagtyp = make_tag_type($3, ENUM, true, false);
+ dcs->d_tag_type = make_tag_type($3, ENUM, true, false);
} enum_declaration /*gcc_attribute_specifier_list_opt*/ {
$$ = complete_enum($5);
}
| enum gcc_attribute_specifier_list_opt {
- dcs->d_tagtyp = make_tag_type(NULL, ENUM, true, false);
+ dcs->d_tag_type = make_tag_type(NULL, ENUM, true, false);
} enum_declaration /*gcc_attribute_specifier_list_opt*/ {
$$ = complete_enum($4);
}
@@ -1450,7 +1450,7 @@ abstract_decl_param_list: /* specific to
}
| abstract_decl_lparen vararg_parameter_type_list T_RPAREN
type_attribute_opt {
- dcs->d_proto = true;
+ dcs->d_prototype = true;
$$ = $2;
}
| abstract_decl_lparen error T_RPAREN type_attribute_opt {
Index: src/usr.bin/xlint/lint1/debug.c
diff -u src/usr.bin/xlint/lint1/debug.c:1.36 src/usr.bin/xlint/lint1/debug.c:1.37
--- src/usr.bin/xlint/lint1/debug.c:1.36 Sat Jun 24 20:50:54 2023
+++ src/usr.bin/xlint/lint1/debug.c Thu Jun 29 22:52:44 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.36 2023/06/24 20:50:54 rillig Exp $ */
+/* $NetBSD: debug.c,v 1.37 2023/06/29 22:52:44 rillig Exp $ */
/*-
* Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: debug.c,v 1.36 2023/06/24 20:50:54 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.37 2023/06/29 22:52:44 rillig Exp $");
#endif
#include <stdlib.h>
@@ -422,14 +422,14 @@ debug_dinfo(const dinfo_t *d) // NOLINT(
debug_word(d->d_invalid_type_combination, "invalid_type_combination");
debug_word(d->d_nonempty_decl, "nonempty_decl");
debug_word(d->d_vararg, "vararg");
- debug_word(d->d_proto, "prototype");
- debug_word(d->d_notyp, "no_type_specifier");
+ debug_word(d->d_prototype, "prototype");
+ debug_word(d->d_no_type_specifier, "no_type_specifier");
debug_word(d->d_asm, "asm");
debug_word(d->d_packed, "packed");
debug_word(d->d_used, "used");
- if (d->d_tagtyp != NULL)
- debug_printf(" tagtyp='%s'", type_name(d->d_tagtyp));
+ if (d->d_tag_type != NULL)
+ debug_printf(" tag_type='%s'", type_name(d->d_tag_type));
for (const sym_t *arg = d->d_func_args;
arg != NULL; arg = arg->s_next)
debug_sym(" arg(", arg, ")");
Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.322 src/usr.bin/xlint/lint1/decl.c:1.323
--- src/usr.bin/xlint/lint1/decl.c:1.322 Thu Jun 29 12:52:06 2023
+++ src/usr.bin/xlint/lint1/decl.c Thu Jun 29 22:52:44 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.322 2023/06/29 12:52:06 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.323 2023/06/29 22:52:44 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.322 2023/06/29 12:52:06 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.323 2023/06/29 22:52:44 rillig Exp $");
#endif
#include <sys/param.h>
@@ -95,7 +95,7 @@ initdecl(void)
/* declaration stack */
dcs = xcalloc(1, sizeof(*dcs));
dcs->d_kind = DK_EXTERN;
- dcs->d_ldlsym = &dcs->d_dlsyms;
+ dcs->d_last_dlsym = &dcs->d_first_dlsym;
if (!pflag) {
for (size_t i = 0; i < NTSPEC; i++)
@@ -561,7 +561,7 @@ begin_declaration_level(declaration_kind
di->d_enclosing = dcs;
dcs = di;
di->d_kind = dk;
- di->d_ldlsym = &di->d_dlsyms;
+ di->d_last_dlsym = &di->d_first_dlsym;
debug_step("%s(%s)", __func__, declaration_kind_name(dk));
}
@@ -589,20 +589,20 @@ end_declaration_level(void)
* symbol table if the symbols of the outer level are
* removed).
*/
- if ((*dcs->d_ldlsym = di->d_dlsyms) != NULL)
- dcs->d_ldlsym = di->d_ldlsym;
+ if ((*dcs->d_last_dlsym = di->d_first_dlsym) != NULL)
+ dcs->d_last_dlsym = di->d_last_dlsym;
break;
case DK_OLD_STYLE_ARG:
/*
- * All symbols in dcs->d_dlsyms are introduced in old-style
- * argument declarations (it's not clean, but possible).
- * They are appended to the list of symbols declared in
- * an old-style argument identifier list or a new style
+ * All symbols in dcs->d_first_dlsym are introduced in
+ * old-style argument declarations (it's not clean, but
+ * possible). They are appended to the list of symbols declared
+ * in an old-style argument identifier list or a new-style
* parameter type list.
*/
- if (di->d_dlsyms != NULL) {
- *di->d_ldlsym = dcs->d_func_proto_syms;
- dcs->d_func_proto_syms = di->d_dlsyms;
+ if (di->d_first_dlsym != NULL) {
+ *di->d_last_dlsym = dcs->d_func_proto_syms;
+ dcs->d_func_proto_syms = di->d_first_dlsym;
}
break;
case DK_ABSTRACT: /* casts and sizeof */
@@ -613,8 +613,8 @@ end_declaration_level(void)
* XXX I'm not sure whether they should be removed from the
* symbol table now or later.
*/
- if ((*dcs->d_ldlsym = di->d_dlsyms) != NULL)
- dcs->d_ldlsym = di->d_ldlsym;
+ if ((*dcs->d_last_dlsym = di->d_first_dlsym) != NULL)
+ dcs->d_last_dlsym = di->d_last_dlsym;
break;
case DK_AUTO:
/* check usage of local vars */
@@ -622,7 +622,7 @@ end_declaration_level(void)
/* FALLTHROUGH */
case DK_PROTO_ARG:
/* usage of arguments will be checked by end_function() */
- rmsyms(di->d_dlsyms);
+ rmsyms(di->d_first_dlsym);
break;
case DK_EXTERN:
/* there is nothing around an external declarations */
@@ -678,7 +678,7 @@ dcs_begin_type(void)
dcs->d_multiple_storage_classes = false;
dcs->d_invalid_type_combination = false;
dcs->d_nonempty_decl = false;
- dcs->d_notyp = false;
+ dcs->d_no_type_specifier = false;
}
static void
@@ -720,7 +720,7 @@ dcs_merge_declaration_specifiers(void)
debug_step("%s: %s", __func__, type_name(tp));
if (t == NO_TSPEC && s == NO_TSPEC && l == NO_TSPEC && c == NO_TSPEC &&
tp == NULL)
- dcs->d_notyp = true;
+ dcs->d_no_type_specifier = true;
if (t == NO_TSPEC && s == NO_TSPEC && (l == NO_TSPEC || l == LONG) &&
tp == NULL)
t = c;
@@ -1369,7 +1369,7 @@ add_function(sym_t *decl, sym_t *args)
debug_sym("arg: ", arg, "\n");
#endif
- if (dcs->d_proto) {
+ if (dcs->d_prototype) {
if (!allow_c90)
/* function prototypes are illegal in traditional C */
warning(270);
@@ -1390,7 +1390,7 @@ add_function(sym_t *decl, sym_t *args)
*/
if (dcs->d_enclosing->d_kind == DK_EXTERN &&
decl->s_type == dcs->d_enclosing->d_type) {
- dcs->d_enclosing->d_func_proto_syms = dcs->d_dlsyms;
+ dcs->d_enclosing->d_func_proto_syms = dcs->d_first_dlsym;
dcs->d_enclosing->d_func_args = args;
}
@@ -1415,7 +1415,7 @@ add_function(sym_t *decl, sym_t *args)
}
*tpp = block_derive_function(dcs->d_enclosing->d_type,
- dcs->d_proto, args, dcs->d_vararg);
+ dcs->d_prototype, args, dcs->d_vararg);
debug_step("add_function: '%s'", type_name(decl->s_type));
debug_leave();
@@ -1432,7 +1432,7 @@ new_style_function(sym_t *args)
* Declarations of structs/unions/enums in param lists are legal,
* but senseless.
*/
- for (sym = dcs->d_dlsyms; sym != NULL; sym = sym->s_level_next) {
+ for (sym = dcs->d_first_dlsym; sym != NULL; sym = sym->s_level_next) {
sc = sym->s_scl;
if (sc == STRUCT_TAG || sc == UNION_TAG || sc == ENUM_TAG) {
/* dubious tag declaration '%s %s' */
@@ -1525,7 +1525,7 @@ declarator_name(sym_t *sym)
case DK_STRUCT_MEMBER:
case DK_UNION_MEMBER:
/* Set parent */
- sym->u.s_member.sm_sou_type = dcs->d_tagtyp->t_sou;
+ sym->u.s_member.sm_sou_type = dcs->d_tag_type->t_sou;
sym->s_def = DEF;
sc = dcs->d_kind == DK_STRUCT_MEMBER
? STRUCT_MEMBER
@@ -1779,7 +1779,7 @@ type_t *
complete_struct_or_union(sym_t *first_member)
{
- type_t *tp = dcs->d_tagtyp;
+ type_t *tp = dcs->d_tag_type;
if (tp == NULL) /* in case of syntax errors */
return gettyp(INT);
@@ -1827,7 +1827,7 @@ type_t *
complete_enum(sym_t *first_enumerator)
{
- type_t *tp = dcs->d_tagtyp;
+ type_t *tp = dcs->d_tag_type;
tp->t_enum->en_incomplete = false;
tp->t_enum->en_first_enumerator = first_enumerator;
return tp;
@@ -1870,7 +1870,7 @@ enumeration_constant(sym_t *sym, int val
}
sym->s_scl = ENUM_CONST;
- sym->s_type = dcs->d_tagtyp;
+ sym->s_type = dcs->d_tag_type;
sym->u.s_enum_constant = val;
if (impl && val == TARG_INT_MIN) {
@@ -2992,7 +2992,8 @@ check_usage(dinfo_t *di)
lwarn = LWARN_ALL;
debug_step("begin lwarn %d", lwarn);
- for (sym_t *sym = di->d_dlsyms; sym != NULL; sym = sym->s_level_next)
+ for (sym_t *sym = di->d_first_dlsym;
+ sym != NULL; sym = sym->s_level_next)
check_usage_sym(di->d_asm, sym);
lwarn = saved_lwarn;
debug_step("end lwarn %d", lwarn);
@@ -3167,7 +3168,7 @@ check_global_symbols(void)
if (block_level != 0 || dcs->d_enclosing != NULL)
norecover();
- for (sym = dcs->d_dlsyms; sym != NULL; sym = sym->s_level_next) {
+ for (sym = dcs->d_first_dlsym; sym != NULL; sym = sym->s_level_next) {
if (sym->s_block_level == -1)
continue;
if (sym->s_kind == FVFT)
Index: src/usr.bin/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.158 src/usr.bin/xlint/lint1/func.c:1.159
--- src/usr.bin/xlint/lint1/func.c:1.158 Thu Jun 29 09:58:36 2023
+++ src/usr.bin/xlint/lint1/func.c Thu Jun 29 22:52:44 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: func.c,v 1.158 2023/06/29 09:58:36 rillig Exp $ */
+/* $NetBSD: func.c,v 1.159 2023/06/29 22:52:44 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: func.c,v 1.158 2023/06/29 09:58:36 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.159 2023/06/29 22:52:44 rillig Exp $");
#endif
#include <stdlib.h>
@@ -341,7 +341,7 @@ begin_function(sym_t *fsym)
warning(286);
}
- if (dcs->d_notyp)
+ if (dcs->d_no_type_specifier)
fsym->s_return_type_implicit_int = true;
set_reached(true);
Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.161 src/usr.bin/xlint/lint1/lex.c:1.162
--- src/usr.bin/xlint/lint1/lex.c:1.161 Sat Jun 24 08:11:12 2023
+++ src/usr.bin/xlint/lint1/lex.c Thu Jun 29 22:52:44 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.161 2023/06/24 08:11:12 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.162 2023/06/29 22:52:44 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: lex.c,v 1.161 2023/06/24 08:11:12 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.162 2023/06/29 22:52:44 rillig Exp $");
#endif
#include <ctype.h>
@@ -1343,8 +1343,8 @@ getsym(sbuf_t *sb)
if (!in_gcc_attribute) {
symtab_add(sym);
- *di->d_ldlsym = sym;
- di->d_ldlsym = &sym->s_level_next;
+ *di->d_last_dlsym = sym;
+ di->d_last_dlsym = &sym->s_level_next;
}
free(sb);
@@ -1379,8 +1379,8 @@ mktempsym(type_t *tp)
symtab_add(sym);
- *dcs->d_ldlsym = sym;
- dcs->d_ldlsym = &sym->s_level_next;
+ *dcs->d_last_dlsym = sym;
+ dcs->d_last_dlsym = &sym->s_level_next;
return sym;
}
@@ -1467,8 +1467,8 @@ pushdown(const sym_t *sym)
symtab_add(nsym);
- *dcs->d_ldlsym = nsym;
- dcs->d_ldlsym = &nsym->s_level_next;
+ *dcs->d_last_dlsym = nsym;
+ dcs->d_last_dlsym = &nsym->s_level_next;
return nsym;
}
Index: src/usr.bin/xlint/lint1/lint1.h
diff -u src/usr.bin/xlint/lint1/lint1.h:1.169 src/usr.bin/xlint/lint1/lint1.h:1.170
--- src/usr.bin/xlint/lint1/lint1.h:1.169 Thu Jun 29 12:52:06 2023
+++ src/usr.bin/xlint/lint1/lint1.h Thu Jun 29 22:52:44 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.169 2023/06/29 12:52:06 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.170 2023/06/29 22:52:44 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -372,16 +372,16 @@ typedef struct dinfo {
bool d_nonempty_decl:1; /* if at least one tag is declared
* ... in the current function decl. */
bool d_vararg:1;
- bool d_proto:1; /* current function decl. is a prototype */
- bool d_notyp:1; /* set if no type specifier was present */
+ bool d_prototype:1; /* current function decl. is a prototype */
+ bool d_no_type_specifier:1;
bool d_asm:1; /* set if d_ctx == AUTO and asm() present */
bool d_packed:1;
bool d_used:1;
- type_t *d_tagtyp; /* tag during member declaration */
+ type_t *d_tag_type; /* tag during member declaration */
sym_t *d_func_args; /* list of arguments during function def. */
pos_t d_func_def_pos; /* position of function definition */
- sym_t *d_dlsyms; /* first symbol declared at this level */
- sym_t **d_ldlsym; /* points to s_level_next in the last symbol
+ sym_t *d_first_dlsym; /* first symbol declared at this level */
+ sym_t **d_last_dlsym; /* points to s_level_next in the last symbol
declaration at this level */
sym_t *d_func_proto_syms; /* symbols defined in prototype */
struct dinfo *d_enclosing; /* the enclosing declaration level */
@@ -389,9 +389,9 @@ typedef struct dinfo {
/* One level of pointer indirection in declarators, including qualifiers. */
typedef struct qual_ptr {
- bool p_const: 1;
- bool p_volatile: 1;
- bool p_pointer: 1;
+ bool p_const:1;
+ bool p_volatile:1;
+ bool p_pointer:1;
struct qual_ptr *p_next;
} qual_ptr;