Module Name: src
Committed By: rillig
Date: Sat Jan 14 10:33:34 UTC 2023
Modified Files:
src/usr.bin/xlint/lint1: cgram.y decl.c lint1.h tree.c
Log Message:
lint: use fewer abbreviations
No binary change except for line numbers in assertions in decl.c.
To generate a diff of this commit:
cvs rdiff -u -r1.424 -r1.425 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.302 -r1.303 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.159 -r1.160 src/usr.bin/xlint/lint1/lint1.h
cvs rdiff -u -r1.491 -r1.492 src/usr.bin/xlint/lint1/tree.c
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.424 src/usr.bin/xlint/lint1/cgram.y:1.425
--- src/usr.bin/xlint/lint1/cgram.y:1.424 Sat Oct 1 09:42:40 2022
+++ src/usr.bin/xlint/lint1/cgram.y Sat Jan 14 10:33:34 2023
@@ -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_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_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_specifier: /* C99 6.7.2.2 */
enum: /* helper for C99 6.7.2.2 */
T_ENUM {
symtyp = FTAG;
- begin_declaration_level(DK_ENUM_CONST);
+ begin_declaration_level(DK_ENUM_CONSTANT);
}
;
Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.302 src/usr.bin/xlint/lint1/decl.c:1.303
--- src/usr.bin/xlint/lint1/decl.c:1.302 Sat Oct 1 10:04:06 2022
+++ src/usr.bin/xlint/lint1/decl.c Sat Jan 14 10:33:34 2023
@@ -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 @@ end_declaration_level(void)
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 @@ declare_bit_field(sym_t *dsym, tspec_t *
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 @@ declarator_1_struct_union(sym_t *dsym)
}
}
- 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 @@ declarator_1_struct_union(sym_t *dsym)
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 @@ set_bit_field_width(sym_t *dsym, int len
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 @@ declarator_name(sym_t *sym)
}
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:
/*
Index: src/usr.bin/xlint/lint1/lint1.h
diff -u src/usr.bin/xlint/lint1/lint1.h:1.159 src/usr.bin/xlint/lint1/lint1.h:1.160
--- src/usr.bin/xlint/lint1/lint1.h:1.159 Fri Jan 13 19:41:50 2023
+++ src/usr.bin/xlint/lint1/lint1.h Sat Jan 14 10:33:34 2023
@@ -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 @@ typedef enum {
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 @@ struct array_size {
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 @@ is_struct_or_union(tspec_t t)
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;
}
Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.491 src/usr.bin/xlint/lint1/tree.c:1.492
--- src/usr.bin/xlint/lint1/tree.c:1.491 Sat Jan 14 10:17:31 2023
+++ src/usr.bin/xlint/lint1/tree.c Sat Jan 14 10:33:34 2023
@@ -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 @@ all_members_compatible(const sym_t *msym
{
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 @@ all_members_compatible(const sym_t *msym
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 @@ struct_or_union_member(tnode_t *tn, op_t
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));