Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: clean up names related to declarat...
details: https://anonhg.NetBSD.org/src/rev/7f9355b88756
branches: trunk
changeset: 377199:7f9355b88756
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Jun 30 21:39:54 2023 +0000
description:
lint: clean up names related to declaration levels
The previous prefix 'DK_' (declaration level kind) had a conflict with
the 'DK_' (designator kind) in init.c, so change the prefix to 'DLK_'.
The new name for dinfo_t is decl_level, which is more expressive.
No functional change.
diffstat:
tests/usr.bin/xlint/lint1/decl_enum.c | 4 +-
usr.bin/xlint/lint1/cgram.y | 22 ++--
usr.bin/xlint/lint1/debug.c | 104 +++++++++++-----------
usr.bin/xlint/lint1/decl.c | 148 +++++++++++++++++-----------------
usr.bin/xlint/lint1/externs1.h | 12 +-
usr.bin/xlint/lint1/func.c | 18 ++--
usr.bin/xlint/lint1/lex.c | 22 ++--
usr.bin/xlint/lint1/lint1.h | 31 +++---
usr.bin/xlint/lint1/tree.c | 10 +-
9 files changed, 185 insertions(+), 186 deletions(-)
diffs (truncated from 933 to 300 lines):
diff -r 4ba740b2e8ac -r 7f9355b88756 tests/usr.bin/xlint/lint1/decl_enum.c
--- a/tests/usr.bin/xlint/lint1/decl_enum.c Fri Jun 30 21:06:18 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/decl_enum.c Fri Jun 30 21:39:54 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl_enum.c,v 1.3 2022/04/16 09:22:25 rillig Exp $ */
+/* $NetBSD: decl_enum.c,v 1.4 2023/06/30 21:39:54 rillig Exp $ */
# 3 "decl_enum.c"
/*
@@ -39,7 +39,7 @@ enum outer {
* enum constant would become the value of the last seen inner enum
* constant. This is because 'enumval' is a simple scalar variable,
* not a stack. If it should ever become necessary to account for
- * nested enum declarations, a field should be added in dinfo_t.
+ * nested enum declarations, a field should be added in decl_level.
*/
o2 __attribute__((__deprecated__)),
o3 = i3
diff -r 4ba740b2e8ac -r 7f9355b88756 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Fri Jun 30 21:06:18 2023 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Fri Jun 30 21:39:54 2023 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.442 2023/06/30 21:06:18 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.443 2023/06/30 21:39:54 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.442 2023/06/30 21:06:18 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.443 2023/06/30 21:39:54 rillig Exp $");
#endif
#include <limits.h>
@@ -897,9 +897,7 @@ struct_or_union_specifier: /* C99 6.7.2.
struct_or_union: /* C99 6.7.2.1 */
T_STRUCT_OR_UNION {
symtyp = FTAG;
- begin_declaration_level($1 == STRUCT
- ? DK_STRUCT_MEMBER
- : DK_UNION_MEMBER);
+ begin_declaration_level($1 == STRUCT ? DLK_STRUCT : DLK_UNION);
dcs->d_offset_in_bits = 0;
dcs->d_sou_align_in_bits = CHAR_SIZE;
$$ = $1;
@@ -1047,7 +1045,7 @@ enum_specifier: /* C99 6.7.2.2 */
enum: /* helper for C99 6.7.2.2 */
T_ENUM {
symtyp = FTAG;
- begin_declaration_level(DK_ENUM_CONSTANT);
+ begin_declaration_level(DLK_ENUM);
}
;
@@ -1318,7 +1316,7 @@ param_list:
id_list_lparen:
T_LPAREN {
block_level++;
- begin_declaration_level(DK_PROTO_ARG);
+ begin_declaration_level(DLK_PROTO_PARAMS);
}
;
@@ -1370,7 +1368,7 @@ identifier_list: /* C99 6.7.5 */
/* XXX: C99 requires an additional specifier-qualifier-list. */
type_name: /* C99 6.7.6 */
{
- begin_declaration_level(DK_ABSTRACT);
+ begin_declaration_level(DLK_ABSTRACT);
} abstract_declaration {
end_declaration_level();
$$ = $2->s_type;
@@ -1453,7 +1451,7 @@ abstract_decl_param_list: /* specific to
abstract_decl_lparen: /* specific to lint */
T_LPAREN {
block_level++;
- begin_declaration_level(DK_PROTO_ARG);
+ begin_declaration_level(DLK_PROTO_PARAMS);
}
;
@@ -1669,7 +1667,7 @@ compound_statement_lbrace:
T_LBRACE {
block_level++;
mem_block_level++;
- begin_declaration_level(DK_AUTO);
+ begin_declaration_level(DLK_AUTO);
}
;
@@ -1819,7 +1817,7 @@ do_while_expr: /* see C99 6.8.5 */
for_start: /* see C99 6.8.5 */
T_FOR T_LPAREN {
- begin_declaration_level(DK_AUTO);
+ begin_declaration_level(DLK_AUTO);
block_level++;
}
;
@@ -1960,7 +1958,7 @@ function_definition: /* C99 6.9.1 */
}
begin_function($1);
block_level++;
- begin_declaration_level(DK_OLD_STYLE_ARG);
+ begin_declaration_level(DLK_OLD_STYLE_ARGS);
if (lwarn == LWARN_NONE)
$1->s_used = true;
} arg_declaration_list_opt {
diff -r 4ba740b2e8ac -r 7f9355b88756 usr.bin/xlint/lint1/debug.c
--- a/usr.bin/xlint/lint1/debug.c Fri Jun 30 21:06:18 2023 +0000
+++ b/usr.bin/xlint/lint1/debug.c Fri Jun 30 21:39:54 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.39 2023/06/30 21:06:18 rillig Exp $ */
+/* $NetBSD: debug.c,v 1.40 2023/06/30 21:39:54 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.39 2023/06/30 21:06:18 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.40 2023/06/30 21:39:54 rillig Exp $");
#endif
#include <stdlib.h>
@@ -250,20 +250,20 @@ def_name(def_t def)
}
const char *
-declaration_kind_name(declaration_kind dk)
+decl_level_kind_name(decl_level_kind kind)
{
static const char *const name[] = {
"extern",
- "member-of-struct",
- "member-of-union",
- "enum-constant",
- "old-style-function-argument",
- "prototype-argument",
+ "struct",
+ "union",
+ "enum",
+ "old-style-function-arguments",
+ "prototype-parameters",
"auto",
"abstract",
};
- return name[dk];
+ return name[kind];
}
const char *
@@ -395,62 +395,62 @@ debug_sym(const char *prefix, const sym_
}
void
-debug_dinfo(const dinfo_t *d) // NOLINT(misc-no-recursion)
+debug_dinfo(const decl_level *dl)
{
debug_print_indent();
- debug_printf("dinfo: %s", declaration_kind_name(d->d_kind));
- if (d->d_scl != NOSCL)
- debug_printf(" %s", scl_name(d->d_scl));
- if (d->d_type != NULL) {
- debug_printf(" '%s'", type_name(d->d_type));
- } else {
- if (d->d_abstract_type != NO_TSPEC)
- debug_printf(" %s", tspec_name(d->d_abstract_type));
- if (d->d_complex_mod != NO_TSPEC)
- debug_printf(" %s", tspec_name(d->d_complex_mod));
- if (d->d_sign_mod != NO_TSPEC)
- debug_printf(" %s", tspec_name(d->d_sign_mod));
- if (d->d_rank_mod != NO_TSPEC)
- debug_printf(" %s", tspec_name(d->d_rank_mod));
+ debug_printf("decl_level: %s", decl_level_kind_name(dl->d_kind));
+ if (dl->d_scl != NOSCL)
+ debug_printf(" %s", scl_name(dl->d_scl));
+ if (dl->d_type != NULL)
+ debug_printf(" '%s'", type_name(dl->d_type));
+ else {
+ if (dl->d_abstract_type != NO_TSPEC)
+ debug_printf(" %s", tspec_name(dl->d_abstract_type));
+ if (dl->d_complex_mod != NO_TSPEC)
+ debug_printf(" %s", tspec_name(dl->d_complex_mod));
+ if (dl->d_sign_mod != NO_TSPEC)
+ debug_printf(" %s", tspec_name(dl->d_sign_mod));
+ if (dl->d_rank_mod != NO_TSPEC)
+ debug_printf(" %s", tspec_name(dl->d_rank_mod));
}
- if (d->d_redeclared_symbol != NULL)
- debug_sym(" redeclared=(", d->d_redeclared_symbol, ")");
- if (d->d_offset_in_bits != 0)
- debug_printf(" offset=%u", d->d_offset_in_bits);
- if (d->d_sou_align_in_bits != 0)
- debug_printf(" align=%u", (unsigned)d->d_sou_align_in_bits);
+ if (dl->d_redeclared_symbol != NULL)
+ debug_sym(" redeclared=(", dl->d_redeclared_symbol, ")");
+ if (dl->d_offset_in_bits != 0)
+ debug_printf(" offset=%u", dl->d_offset_in_bits);
+ if (dl->d_sou_align_in_bits != 0)
+ debug_printf(" align=%u", (unsigned)dl->d_sou_align_in_bits);
- debug_word(d->d_const, "const");
- debug_word(d->d_volatile, "volatile");
- debug_word(d->d_inline, "inline");
- debug_word(d->d_multiple_storage_classes, "multiple_storage_classes");
- 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_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");
+ debug_word(dl->d_const, "const");
+ debug_word(dl->d_volatile, "volatile");
+ debug_word(dl->d_inline, "inline");
+ debug_word(dl->d_multiple_storage_classes, "multiple_storage_classes");
+ debug_word(dl->d_invalid_type_combination, "invalid_type_combination");
+ debug_word(dl->d_nonempty_decl, "nonempty_decl");
+ debug_word(dl->d_vararg, "vararg");
+ debug_word(dl->d_prototype, "prototype");
+ debug_word(dl->d_no_type_specifier, "no_type_specifier");
+ debug_word(dl->d_asm, "asm");
+ debug_word(dl->d_packed, "packed");
+ debug_word(dl->d_used, "used");
- 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;
+ if (dl->d_tag_type != NULL)
+ debug_printf(" tag_type='%s'", type_name(dl->d_tag_type));
+ for (const sym_t *arg = dl->d_func_args;
arg != NULL; arg = arg->s_next)
debug_sym(" arg(", arg, ")");
- if (d->d_func_def_pos.p_file != NULL)
- debug_printf(" func_def_pos=%s:%d:%d",
- d->d_func_def_pos.p_file, d->d_func_def_pos.p_line,
- d->d_func_def_pos.p_uniq);
- for (const sym_t *sym = d->d_func_proto_syms;
+ if (dl->d_func_def_pos.p_file != NULL)
+ debug_printf(" func_def_pos=%s:%dl:%dl",
+ dl->d_func_def_pos.p_file, dl->d_func_def_pos.p_line,
+ dl->d_func_def_pos.p_uniq);
+ for (const sym_t *sym = dl->d_func_proto_syms;
sym != NULL; sym = sym->s_next)
debug_sym(" func_proto_sym(", sym, ")");
debug_printf("\n");
- if (d->d_enclosing != NULL) {
+ if (dl->d_enclosing != NULL) {
debug_indent_inc();
- debug_dinfo(d->d_enclosing);
+ debug_dinfo(dl->d_enclosing);
debug_indent_dec();
}
}
diff -r 4ba740b2e8ac -r 7f9355b88756 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c Fri Jun 30 21:06:18 2023 +0000
+++ b/usr.bin/xlint/lint1/decl.c Fri Jun 30 21:39:54 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.329 2023/06/30 21:06:18 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.330 2023/06/30 21:39:54 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.329 2023/06/30 21:06:18 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.330 2023/06/30 21:39:54 rillig Exp $");
#endif
#include <sys/param.h>
@@ -57,10 +57,11 @@ static type_t typetab[NTSPEC];
int enumval;
/*
- * pointer to innermost element of a stack which contains information local
- * to nested declarations
+ * Points to the innermost element of a stack that contains information about
+ * nested declarations, such as struct declarations, function prototypes,
+ * local variables.
*/
-dinfo_t *dcs;
+decl_level *dcs;
static type_t *typedef_error(type_t *, tspec_t);
static void set_first_typedef(type_t *, sym_t *);
@@ -94,7 +95,7 @@ initdecl(void)
/* declaration stack */
dcs = xcalloc(1, sizeof(*dcs));
Home |
Main Index |
Thread Index |
Old Index