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: rename dinfo_t.d_next to d_enclosing



details:   https://anonhg.NetBSD.org/src/rev/81a2448ef7a6
branches:  trunk
changeset: 364641:81a2448ef7a6
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Apr 02 14:28:30 2022 +0000

description:
lint: rename dinfo_t.d_next to d_enclosing

The name d_next gave the wrong impression that the declaration infos
would be independent of each other, but they are nested.

No functional change.

diffstat:

 usr.bin/xlint/lint1/debug.c |   8 +++---
 usr.bin/xlint/lint1/decl.c  |  60 ++++++++++++++++++++++----------------------
 usr.bin/xlint/lint1/func.c  |  10 +++---
 usr.bin/xlint/lint1/lex.c   |   9 +++---
 usr.bin/xlint/lint1/lint1.h |   4 +-
 usr.bin/xlint/lint1/tree.c  |   6 ++--
 6 files changed, 49 insertions(+), 48 deletions(-)

diffs (truncated from 322 to 300 lines):

diff -r 4dcf8392705b -r 81a2448ef7a6 usr.bin/xlint/lint1/debug.c
--- a/usr.bin/xlint/lint1/debug.c       Sat Apr 02 12:24:54 2022 +0000
+++ b/usr.bin/xlint/lint1/debug.c       Sat Apr 02 14:28:30 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.10 2022/04/02 12:24:54 rillig Exp $ */
+/* $NetBSD: debug.c,v 1.11 2022/04/02 14:28:30 rillig Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: debug.c,v 1.10 2022/04/02 12:24:54 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.11 2022/04/02 14:28:30 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -363,9 +363,9 @@
                debug_sym("func_proto_sym(", sym, ")");
        debug_printf("\n");
 
-       if (d->d_next != NULL) {
+       if (d->d_enclosing != NULL) {
                debug_indent_inc();
-               debug_dinfo(d->d_next);
+               debug_dinfo(d->d_enclosing);
                debug_indent_dec();
        }
 }
diff -r 4dcf8392705b -r 81a2448ef7a6 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Sat Apr 02 12:24:54 2022 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Sat Apr 02 14:28:30 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.258 2022/04/02 12:24:54 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.259 2022/04/02 14:28:30 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.258 2022/04/02 12:24:54 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.259 2022/04/02 14:28:30 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -599,7 +599,7 @@
 
        /* put a new element on the declaration stack */
        di = xcalloc(1, sizeof(*di));
-       di->d_next = dcs;
+       di->d_enclosing = dcs;
        dcs = di;
        di->d_ctx = sc;
        di->d_ldlsym = &di->d_dlsyms;
@@ -616,9 +616,9 @@
 
        debug_step("%s(%p %s)", __func__, dcs, scl_name(dcs->d_ctx));
 
-       lint_assert(dcs->d_next != NULL);
+       lint_assert(dcs->d_enclosing != NULL);
        di = dcs;
-       dcs = di->d_next;
+       dcs = di->d_enclosing;
        switch (di->d_ctx) {
        case MOS:
        case MOU:
@@ -696,7 +696,7 @@
 {
        dinfo_t *di;
 
-       for (di = dcs; di != NULL; di = di->d_next)
+       for (di = dcs; di != NULL; di = di->d_enclosing)
                di->d_asm = true;
 }
 
@@ -1393,17 +1393,17 @@
        /*
         * The symbols are removed from the symbol table by
         * end_declaration_level after add_function. To be able to restore
-        * them if this is a function definition, a pointer to the list of all
-        * symbols is stored in dcs->d_next->d_func_proto_syms. Also a list of
-        * the arguments (concatenated by s_next) is stored in
-        * dcs->d_next->d_func_args. (dcs->d_next must be used because *dcs is
-        * the declaration stack element created for the list of params and is
-        * removed after add_function.)
+        * them if this is a function definition, a pointer to the list of
+        * all symbols is stored in dcs->d_enclosing->d_func_proto_syms. Also
+        * a list of the arguments (concatenated by s_next) is stored in
+        * dcs->d_enclosing->d_func_args. (dcs->d_enclosing must be used
+        * because *dcs is the declaration stack element created for the list
+        * of params and is removed after add_function.)
         */
-       if (dcs->d_next->d_ctx == EXTERN &&
-           decl->s_type == dcs->d_next->d_type) {
-               dcs->d_next->d_func_proto_syms = dcs->d_dlsyms;
-               dcs->d_next->d_func_args = args;
+       if (dcs->d_enclosing->d_ctx == EXTERN &&
+           decl->s_type == dcs->d_enclosing->d_type) {
+               dcs->d_enclosing->d_func_proto_syms = dcs->d_dlsyms;
+               dcs->d_enclosing->d_func_args = args;
        }
 
        /*
@@ -1412,8 +1412,8 @@
         */
        tpp = &decl->s_type;
        if (*tpp == NULL)
-               decl->s_type = dcs->d_next->d_type;
-       while (*tpp != NULL && *tpp != dcs->d_next->d_type)
+               decl->s_type = dcs->d_enclosing->d_type;
+       while (*tpp != NULL && *tpp != dcs->d_enclosing->d_type)
                /*
                 * XXX: accessing INT->t_subt feels strange, even though it
                 * may even be guaranteed to be NULL.
@@ -1428,7 +1428,7 @@
 
        *tpp = tp = block_zero_alloc(sizeof(*tp));
        tp->t_tspec = FUNC;
-       tp->t_subt = dcs->d_next->d_type;
+       tp->t_subt = dcs->d_enclosing->d_type;
        if ((tp->t_proto = dcs->d_proto) != false)
                tp->t_args = args;
        tp->t_vararg = dcs->d_vararg;
@@ -1485,8 +1485,8 @@
         * Remember list of parameters only if this really seems to be a
         * function definition.
         */
-       if (dcs->d_next->d_ctx == EXTERN &&
-           decl->s_type == dcs->d_next->d_type) {
+       if (dcs->d_enclosing->d_ctx == EXTERN &&
+           decl->s_type == dcs->d_enclosing->d_type) {
                /*
                 * We assume that this becomes a function definition. If
                 * we are wrong, it's corrected in check_function_definition.
@@ -1670,7 +1670,7 @@
                        tag = newtag(tag, scl, decl, semi);
                } else {
                        /* a new tag, no empty declaration */
-                       dcs->d_next->d_nonempty_decl = true;
+                       dcs->d_enclosing->d_nonempty_decl = true;
                        if (scl == ENUM_TAG && !decl) {
                                if (!tflag && (sflag || pflag))
                                        /* forward reference to enum type */
@@ -1693,7 +1693,7 @@
                tag->s_block_level = -1;
                tag->s_type = tp = block_zero_alloc(sizeof(*tp));
                tp->t_packed = dcs->d_packed;
-               dcs->d_next->d_nonempty_decl = true;
+               dcs->d_enclosing->d_nonempty_decl = true;
        }
 
        if (tp->t_tspec == NOTSPEC) {
@@ -1735,14 +1735,14 @@
                                warning(45, storage_class_name(tag->s_scl),
                                    tag->s_name);
                        }
-                       dcs->d_next->d_nonempty_decl = true;
+                       dcs->d_enclosing->d_nonempty_decl = true;
                } else if (decl) {
                        /* "struct a { ... } " */
                        if (hflag)
                                /* redefinition hides earlier one: %s */
                                warning(43, tag->s_name);
                        tag = pushdown(tag);
-                       dcs->d_next->d_nonempty_decl = true;
+                       dcs->d_enclosing->d_nonempty_decl = true;
                } else if (tag->s_scl != scl) {
                        /* base type is really '%s %s' */
                        warning(45, storage_class_name(tag->s_scl),
@@ -1753,7 +1753,7 @@
                                    tag->s_name);
                        }
                        tag = pushdown(tag);
-                       dcs->d_next->d_nonempty_decl = true;
+                       dcs->d_enclosing->d_nonempty_decl = true;
                }
        } else {
                if (tag->s_scl != scl ||
@@ -1763,9 +1763,9 @@
                            tag->s_name, storage_class_name(scl));
                        print_previous_declaration(-1, tag);
                        tag = pushdown(tag);
-                       dcs->d_next->d_nonempty_decl = true;
+                       dcs->d_enclosing->d_nonempty_decl = true;
                } else if (semi || decl) {
-                       dcs->d_next->d_nonempty_decl = true;
+                       dcs->d_enclosing->d_nonempty_decl = true;
                }
        }
        return tag;
@@ -2908,7 +2908,7 @@
 global_clean_up(void)
 {
 
-       while (dcs->d_next != NULL)
+       while (dcs->d_enclosing != NULL)
                end_declaration_level();
 
        clean_up_after_error();
@@ -3180,7 +3180,7 @@
 {
        sym_t   *sym;
 
-       if (block_level != 0 || dcs->d_next != NULL)
+       if (block_level != 0 || dcs->d_enclosing != NULL)
                norecover();
 
        for (sym = dcs->d_dlsyms; sym != NULL; sym = sym->s_level_next) {
diff -r 4dcf8392705b -r 81a2448ef7a6 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c        Sat Apr 02 12:24:54 2022 +0000
+++ b/usr.bin/xlint/lint1/func.c        Sat Apr 02 14:28:30 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: func.c,v 1.128 2022/02/27 10:44:45 rillig Exp $        */
+/*     $NetBSD: func.c,v 1.129 2022/04/02 14:28:30 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.128 2022/02/27 10:44:45 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.129 2022/04/02 14:28:30 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -415,14 +415,14 @@
        }
 
        /* clean up after syntax errors, see test stmt_for.c. */
-       while (dcs->d_next != NULL)
-               dcs = dcs->d_next;
+       while (dcs->d_enclosing != NULL)
+               dcs = dcs->d_enclosing;
 
        /*
         * remove all symbols declared during argument declaration from
         * the symbol table
         */
-       lint_assert(dcs->d_next == NULL);
+       lint_assert(dcs->d_enclosing == NULL);
        lint_assert(dcs->d_ctx == EXTERN);
        rmsyms(dcs->d_func_proto_syms);
 
diff -r 4dcf8392705b -r 81a2448ef7a6 usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Sat Apr 02 12:24:54 2022 +0000
+++ b/usr.bin/xlint/lint1/lex.c Sat Apr 02 14:28:30 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.114 2022/04/02 12:24:55 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.115 2022/04/02 14:28:30 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: lex.c,v 1.114 2022/04/02 12:24:55 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.115 2022/04/02 14:28:30 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -1414,8 +1414,9 @@
                sym->s_name = s;
                sym->s_block_level = 1;
                di = dcs;
-               while (di->d_next != NULL && di->d_next->d_next != NULL)
-                       di = di->d_next;
+               while (di->d_enclosing != NULL &&
+                   di->d_enclosing->d_enclosing != NULL)
+                       di = di->d_enclosing;
                lint_assert(di->d_ctx == AUTO);
        } else {
                sym = block_zero_alloc(sizeof(*sym));
diff -r 4dcf8392705b -r 81a2448ef7a6 usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h       Sat Apr 02 12:24:54 2022 +0000
+++ b/usr.bin/xlint/lint1/lint1.h       Sat Apr 02 14:28:30 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.142 2022/02/27 18:29:14 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.143 2022/04/02 14:28:30 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -385,7 +385,7 @@
        sym_t   **d_ldlsym;     /* 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_next;  /* next level */
+       struct dinfo *d_enclosing; /* the enclosing declaration level */
 } dinfo_t;
 
 /* One level of pointer indirection in declarators, including qualifiers. */
diff -r 4dcf8392705b -r 81a2448ef7a6 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sat Apr 02 12:24:54 2022 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sat Apr 02 14:28:30 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.415 2022/04/02 12:24:55 rillig Exp $        */



Home | Main Index | Thread Index | Old Index