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 members of brace_level



details:   https://anonhg.NetBSD.org/src/rev/668fad1ae88f
branches:  trunk
changeset: 982147:668fad1ae88f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Apr 02 14:32:27 2021 +0000

description:
lint: rename members of brace_level

The terms 'member' and 'subscript' are distinctive enough.

No functional change.

diffstat:

 usr.bin/xlint/lint1/init.c |  52 ++++++++++++++++++++++-----------------------
 1 files changed, 25 insertions(+), 27 deletions(-)

diffs (163 lines):

diff -r d3a429ba5e4a -r 668fad1ae88f usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Fri Apr 02 14:19:33 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c        Fri Apr 02 14:32:27 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.191 2021/04/02 14:19:33 rillig Exp $        */
+/*     $NetBSD: init.c,v 1.192 2021/04/02 14:32:27 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.191 2021/04/02 14:19:33 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.192 2021/04/02 14:32:27 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -122,11 +122,13 @@
         * level.
         */
        const type_t    *bl_type;
-       const sym_t     *bl_next_member;        /* for structs and unions */
-       size_t          bl_array_next_subscript;
+
+       const sym_t     *bl_member;             /* for structs and unions */
+       size_t          bl_subscript;           /* for arrays */
        bool            bl_scalar_done: 1;      /* for scalars */
        bool            bl_confused: 1;         /* skip further checks */
        struct designation bl_designation;      /* .member[123].member */
+
        struct brace_level *bl_enclosing;
 };
 
@@ -549,7 +551,7 @@
        bl->bl_type = tp;
        bl->bl_enclosing = enclosing;
        if (is_struct_or_union(tp->t_tspec))
-               bl->bl_next_member = first_named_member(tp);
+               bl->bl_member = first_named_member(tp);
 
        return bl;
 }
@@ -568,18 +570,14 @@
 {
 
        lint_assert(bl->bl_type != NULL);
-       lint_assert(bl->bl_next_member == NULL ||
-           !is_unnamed(bl->bl_next_member));
+       lint_assert(bl->bl_member == NULL || !is_unnamed(bl->bl_member));
 
        debug_printf("type '%s'", type_name(bl->bl_type));
 
-       if (is_struct_or_union(bl->bl_type->t_tspec) &&
-           bl->bl_next_member != NULL)
-               debug_printf(", next member '%s'",
-                   bl->bl_next_member->s_name);
+       if (is_struct_or_union(bl->bl_type->t_tspec) && bl->bl_member != NULL)
+               debug_printf(", member '%s'", bl->bl_member->s_name);
        if (bl->bl_type->t_tspec == ARRAY)
-               debug_printf(", next array subscript %zu",
-                   bl->bl_array_next_subscript);
+               debug_printf(", subscript %zu", bl->bl_subscript);
 
        debug_printf("\n");
 }
@@ -591,14 +589,14 @@
 brace_level_sub_type_struct_or_union(const struct brace_level *bl)
 {
 
-       if (bl->bl_next_member == NULL) {
+       if (bl->bl_member == NULL) {
                /* too many struct/union initializers */
                error(172);
                return NULL;
        }
 
-       lint_assert(!is_unnamed(bl->bl_next_member));
-       return sym_type(bl->bl_next_member);
+       lint_assert(!is_unnamed(bl->bl_member));
+       return sym_type(bl->bl_member);
 }
 
 static const type_t *
@@ -606,7 +604,7 @@
 {
 
        if (!bl->bl_confused && !bl->bl_type->t_incomplete_array &&
-           bl->bl_array_next_subscript >= (size_t)bl->bl_type->t_dim) {
+           bl->bl_subscript >= (size_t)bl->bl_type->t_dim) {
                /* too many array initializers, expected %d */
                error(173, bl->bl_type->t_dim);
        }
@@ -645,6 +643,7 @@
        }
 }
 
+/* C99 6.7.8p17 */
 static void
 brace_level_apply_designation(struct brace_level *bl)
 {
@@ -660,12 +659,12 @@
        case UNION:
                if (dr->dr_name == NULL)
                        return; /* error, silently ignored */
-               bl->bl_next_member = look_up_member(bl->bl_type, dr->dr_name);
+               bl->bl_member = look_up_member(bl->bl_type, dr->dr_name);
                break;
        case ARRAY:
                if (dr->dr_name != NULL)
                        return; /* error, silently ignored */
-               bl->bl_array_next_subscript = dr->dr_subscript;
+               bl->bl_subscript = dr->dr_subscript;
                break;
        default:
                break;          /* error, silently ignored */
@@ -683,14 +682,14 @@
 
        switch (bl->bl_type->t_tspec) {
        case STRUCT:
-               lint_assert(bl->bl_next_member != NULL);
-               bl->bl_next_member = skip_unnamed(bl->bl_next_member->s_next);
+               lint_assert(bl->bl_member != NULL);
+               bl->bl_member = skip_unnamed(bl->bl_member->s_next);
                break;
        case UNION:
-               bl->bl_next_member = NULL;
+               bl->bl_member = NULL;
                break;
        case ARRAY:
-               bl->bl_array_next_subscript++;
+               bl->bl_subscript++;
                break;
        default:
                bl->bl_scalar_done = true;
@@ -813,7 +812,7 @@
        if (in->in_sym->s_type->t_incomplete_array &&
            in->in_brace_level->bl_enclosing == NULL)
                update_type_of_array_of_unknown_size(in->in_sym,
-                   in->in_brace_level->bl_array_next_subscript);
+                   in->in_brace_level->bl_subscript);
 }
 
 static void
@@ -900,8 +899,7 @@
 
        if (!is_string_array(tp, strg->st_tspec))
                return false;
-       if (bl != NULL && tp->t_tspec != ARRAY &&
-           bl->bl_array_next_subscript != 0)
+       if (bl != NULL && tp->t_tspec != ARRAY && bl->bl_subscript != 0)
                return false;
 
        if (bl != NULL && tp->t_dim < (int)strg->st_len) {
@@ -911,7 +909,7 @@
 
        if (tp == in->in_sym->s_type && tp->t_incomplete_array) {
                if (bl != NULL) {
-                       bl->bl_array_next_subscript = strg->st_len + 1;
+                       bl->bl_subscript = strg->st_len + 1;
                        /* see initialization_set_size_of_unknown_array */
                } else
                        update_type_of_array_of_unknown_size(in->in_sym,



Home | Main Index | Thread Index | Old Index