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: use fewer abbreviations



details:   https://anonhg.NetBSD.org/src/rev/789ed33d4980
branches:  trunk
changeset: 373034:789ed33d4980
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jan 14 10:33:34 2023 +0000

description:
lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.

diffstat:

 usr.bin/xlint/lint1/cgram.y |  10 ++++++----
 usr.bin/xlint/lint1/decl.c  |  26 ++++++++++++++------------
 usr.bin/xlint/lint1/lint1.h |  14 +++++++-------
 usr.bin/xlint/lint1/tree.c  |  10 +++++-----
 4 files changed, 32 insertions(+), 28 deletions(-)

diffs (210 lines):

diff -r 620a1b200650 -r 789ed33d4980 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sat Jan 14 10:17:31 2023 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sat Jan 14 10:33:34 2023 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.424 2022/10/01 09:42:40 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.425 2023/01/14 10:33:34 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.424 2022/10/01 09:42:40 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.425 2023/01/14 10:33:34 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -893,7 +893,9 @@
 struct_or_union:               /* C99 6.7.2.1 */
          T_STRUCT_OR_UNION {
                symtyp = FTAG;
-               begin_declaration_level($1 == STRUCT ? DK_MOS : DK_MOU);
+               begin_declaration_level($1 == STRUCT
+                   ? DK_STRUCT_MEMBER
+                   : DK_UNION_MEMBER);
                dcs->d_offset_in_bits = 0;
                dcs->d_sou_align_in_bits = CHAR_SIZE;
                $$ = $1;
@@ -1043,7 +1045,7 @@
 enum:                          /* helper for C99 6.7.2.2 */
          T_ENUM {
                symtyp = FTAG;
-               begin_declaration_level(DK_ENUM_CONST);
+               begin_declaration_level(DK_ENUM_CONSTANT);
          }
        ;
 
diff -r 620a1b200650 -r 789ed33d4980 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Sat Jan 14 10:17:31 2023 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Sat Jan 14 10:33:34 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.302 2022/10/01 10:04:06 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.303 2023/01/14 10:33:34 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.302 2022/10/01 10:04:06 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.303 2023/01/14 10:33:34 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -598,9 +598,9 @@
        dcs = di->d_enclosing;
 
        switch (di->d_kind) {
-       case DK_MOS:
-       case DK_MOU:
-       case DK_ENUM_CONST:
+       case DK_STRUCT_MEMBER:
+       case DK_UNION_MEMBER:
+       case DK_ENUM_CONSTANT:
                /*
                 * Symbols declared in (nested) structs or enums are
                 * part of the next level (they are removed from the
@@ -1095,7 +1095,7 @@
                error(37);
                tp->t_flen = size_in_bits(t);
        }
-       if (dsym->s_scl == MOU) {
+       if (dsym->s_scl == UNION_MEMBER) {
                /* bit-field in union is very unusual */
                warning(41);
                dsym->s_type->t_bitfield = false;
@@ -1151,7 +1151,7 @@
                }
        }
 
-       if (dcs->d_kind == DK_MOU) {
+       if (dcs->d_kind == DK_UNION_MEMBER) {
                o = dcs->d_offset_in_bits;
                dcs->d_offset_in_bits = 0;
        }
@@ -1167,7 +1167,7 @@
                dsym->u.s_member.sm_offset_in_bits = dcs->d_offset_in_bits;
                dcs->d_offset_in_bits += sz;
        }
-       if (dcs->d_kind == DK_MOU && o > dcs->d_offset_in_bits)
+       if (dcs->d_kind == DK_UNION_MEMBER && o > dcs->d_offset_in_bits)
                dcs->d_offset_in_bits = o;
 
        check_function_definition(dsym, false);
@@ -1215,7 +1215,7 @@
                dsym = block_zero_alloc(sizeof(*dsym));
                dsym->s_name = unnamed;
                dsym->s_kind = FMEMBER;
-               dsym->s_scl = MOS;
+               dsym->s_scl = STRUCT_MEMBER;
                dsym->s_type = gettyp(UINT);
                dsym->s_block_level = -1;
        }
@@ -1555,13 +1555,15 @@
        }
 
        switch (dcs->d_kind) {
-       case DK_MOS:
-       case DK_MOU:
+       case DK_STRUCT_MEMBER:
+       case DK_UNION_MEMBER:
                /* Set parent */
                sym->u.s_member.sm_sou_type = dcs->d_tagtyp->t_str;
                sym->s_def = DEF;
                /* XXX: Where is sym->u.s_member.sm_offset_in_bits set? */
-               sc = dcs->d_kind == DK_MOS ? MOS : MOU;
+               sc = dcs->d_kind == DK_STRUCT_MEMBER
+                   ? STRUCT_MEMBER
+                   : UNION_MEMBER;
                break;
        case DK_EXTERN:
                /*
diff -r 620a1b200650 -r 789ed33d4980 usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h       Sat Jan 14 10:17:31 2023 +0000
+++ b/usr.bin/xlint/lint1/lint1.h       Sat Jan 14 10:33:34 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.159 2023/01/13 19:41:50 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.160 2023/01/14 10:33:34 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -214,8 +214,8 @@
        STRUCT_TAG,
        UNION_TAG,
        ENUM_TAG,
-       MOS,            /* member of struct */
-       MOU,            /* member of union */
+       STRUCT_MEMBER,
+       UNION_MEMBER,
        BOOL_CONST,
        ENUM_CONST,
        ABSTRACT,       /* abstract symbol (sizeof, casts, unnamed argument) */
@@ -335,9 +335,9 @@
 
 typedef enum declaration_kind {
        DK_EXTERN,              /* global variable or function */
-       DK_MOS,                 /* struct member */
-       DK_MOU,                 /* union member */
-       DK_ENUM_CONST,          /* enum constant */
+       DK_STRUCT_MEMBER,
+       DK_UNION_MEMBER,
+       DK_ENUM_CONSTANT,
        DK_OLD_STYLE_ARG,       /* argument in an old-style function
                                 * definition */
        DK_PROTO_ARG,           /* argument in a prototype function
@@ -596,5 +596,5 @@
 static inline bool
 is_member(const sym_t *sym)
 {
-       return sym->s_scl == MOS || sym->s_scl == MOU;
+       return sym->s_scl == STRUCT_MEMBER || sym->s_scl == UNION_MEMBER;
 }
diff -r 620a1b200650 -r 789ed33d4980 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sat Jan 14 10:17:31 2023 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sat Jan 14 10:33:34 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.491 2023/01/14 10:17:31 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.492 2023/01/14 10:33:34 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.491 2023/01/14 10:17:31 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.492 2023/01/14 10:33:34 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -564,7 +564,7 @@
 {
        for (const sym_t *csym = msym;
             csym != NULL; csym = csym->s_symtab_next) {
-               if (csym->s_scl != MOS && csym->s_scl != MOU)
+               if (!is_member(csym))
                        continue;
                if (strcmp(msym->s_name, csym->s_name) != 0)
                        continue;
@@ -572,7 +572,7 @@
                for (const sym_t *sym = csym->s_symtab_next;
                     sym != NULL; sym = sym->s_symtab_next) {
 
-                       if (sym->s_scl != MOS && sym->s_scl != MOU)
+                       if (!is_member(sym))
                                continue;
                        if (strcmp(csym->s_name, sym->s_name) != 0)
                                continue;
@@ -619,7 +619,7 @@
                error(101, type_name(tn->tn_type), msym->s_name);
                rmsym(msym);
                msym->s_kind = FMEMBER;
-               msym->s_scl = MOS;
+               msym->s_scl = STRUCT_MEMBER;
 
                struct_or_union *sou = expr_zero_alloc(sizeof(*sou));
                sou->sou_tag = expr_zero_alloc(sizeof(*sou->sou_tag));



Home | Main Index | Thread Index | Old Index