Module Name: src
Committed By: rillig
Date: Sun Aug 28 08:41:06 UTC 2022
Modified Files:
src/tests/usr.bin/xlint/lint1: decl.c queries.c
src/usr.bin/xlint/lint1: cgram.y decl.c externs1.h lint1.h
Log Message:
lint: rename dcs manipulation functions to be clearer
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/tests/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/queries.c
cvs rdiff -u -r1.421 -r1.422 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.295 -r1.296 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.165 -r1.166 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.156 -r1.157 src/usr.bin/xlint/lint1/lint1.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/xlint/lint1/decl.c
diff -u src/tests/usr.bin/xlint/lint1/decl.c:1.18 src/tests/usr.bin/xlint/lint1/decl.c:1.19
--- src/tests/usr.bin/xlint/lint1/decl.c:1.18 Wed Jun 22 19:23:18 2022
+++ src/tests/usr.bin/xlint/lint1/decl.c Sun Aug 28 08:41:06 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.18 2022/06/22 19:23:18 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.19 2022/08/28 08:41:06 rillig Exp $ */
# 3 "decl.c"
/*
@@ -144,7 +144,7 @@ struct {
/*
* Before decl.c 1.201 from 2021-07-15, lint crashed with an internal error
- * in end_type.
+ * in dcs_end_type (named end_type back then).
*/
unsigned long sizes =
sizeof(const typeof(bool)) +
Index: src/tests/usr.bin/xlint/lint1/queries.c
diff -u src/tests/usr.bin/xlint/lint1/queries.c:1.3 src/tests/usr.bin/xlint/lint1/queries.c:1.4
--- src/tests/usr.bin/xlint/lint1/queries.c:1.3 Fri Jul 8 21:19:07 2022
+++ src/tests/usr.bin/xlint/lint1/queries.c Sun Aug 28 08:41:06 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: queries.c,v 1.3 2022/07/08 21:19:07 rillig Exp $ */
+/* $NetBSD: queries.c,v 1.4 2022/08/28 08:41:06 rillig Exp $ */
# 3 "queries.c"
/*
@@ -173,7 +173,7 @@ Q7(void)
/*
* Neither GCC nor Clang accept typeof(bit-field), as that would add
* unnecessary complexity. Lint accepts it but silently discards the
- * bit-field portion from the type; see add_type.
+ * bit-field portion from the type; see dcs_add_type.
*/
/* expect+1: redundant cast from 'unsigned char' to 'unsigned int' before assignment [Q7] */
bits.u9 = (typeof(bits.u9))u8;
Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.421 src/usr.bin/xlint/lint1/cgram.y:1.422
--- src/usr.bin/xlint/lint1/cgram.y:1.421 Thu Aug 25 19:03:47 2022
+++ src/usr.bin/xlint/lint1/cgram.y Sun Aug 28 08:41:06 2022
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.421 2022/08/25 19:03:47 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.422 2022/08/28 08:41:06 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.421 2022/08/25 19:03:47 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.422 2022/08/28 08:41:06 rillig Exp $");
#endif
#include <limits.h>
@@ -730,24 +730,24 @@ declaration: /* C99 6.7 */
begin_type_declaration_specifiers: /* see C99 6.7 */
begin_type_typespec {
- add_type($1);
+ dcs_add_type($1);
}
| begin_type_declmods type_specifier {
- add_type($2);
+ dcs_add_type($2);
}
| type_attribute begin_type_declaration_specifiers
| begin_type_declaration_specifiers declmod
| begin_type_declaration_specifiers notype_type_specifier {
- add_type($2);
+ dcs_add_type($2);
}
;
begin_type_declmods: /* see C99 6.7 */
begin_type T_QUAL {
- add_qualifier($2);
+ dcs_add_qualifier($2);
}
| begin_type T_SCLASS {
- add_storage_class($2);
+ dcs_add_storage_class($2);
}
| begin_type_declmods declmod
;
@@ -759,16 +759,16 @@ begin_type_specifier_qualifier_list: /*
begin_type_specifier_qualifier_list_postfix:
begin_type_typespec {
- add_type($1);
+ dcs_add_type($1);
}
| begin_type_qualifier_list type_specifier {
- add_type($2);
+ dcs_add_type($2);
}
| begin_type_specifier_qualifier_list_postfix T_QUAL {
- add_qualifier($2);
+ dcs_add_qualifier($2);
}
| begin_type_specifier_qualifier_list_postfix notype_type_specifier {
- add_type($2);
+ dcs_add_type($2);
}
| begin_type_specifier_qualifier_list_postfix type_attribute
;
@@ -784,19 +784,19 @@ begin_type_typespec:
begin_type_qualifier_list:
begin_type T_QUAL {
- add_qualifier($2);
+ dcs_add_qualifier($2);
}
| begin_type_qualifier_list T_QUAL {
- add_qualifier($2);
+ dcs_add_qualifier($2);
}
;
declmod:
T_QUAL {
- add_qualifier($1);
+ dcs_add_qualifier($1);
}
| T_SCLASS {
- add_storage_class($1);
+ dcs_add_storage_class($1);
}
| type_attribute_list
;
@@ -821,20 +821,20 @@ type_attribute: /* See C11 6.7 declara
| T_ALIGNAS T_LPAREN type_specifier T_RPAREN /* C11 6.7.5 */
| T_ALIGNAS T_LPAREN constant_expr T_RPAREN /* C11 6.7.5 */
| T_PACKED {
- addpacked();
+ dcs_add_packed();
}
| T_NORETURN
;
begin_type:
/* empty */ {
- begin_type();
+ dcs_begin_type();
}
;
end_type:
/* empty */ {
- end_type();
+ dcs_end_type();
}
;
@@ -1852,10 +1852,10 @@ goto: /* see C99 6.8.6 */
asm_statement: /* GCC extension */
T_ASM T_LPAREN read_until_rparen T_SEMI {
- setasm();
+ dcs_set_asm();
}
| T_ASM T_QUAL T_LPAREN read_until_rparen T_SEMI {
- setasm();
+ dcs_set_asm();
}
| T_ASM error
;
@@ -2045,10 +2045,10 @@ gcc_attribute:
| T_NAME {
const char *name = $1->sb_name;
if (is_either(name, "packed", "__packed__"))
- addpacked();
+ dcs_add_packed();
else if (is_either(name, "used", "__used__") ||
is_either(name, "unused", "__unused__"))
- add_attr_used();
+ dcs_set_used();
else if (is_either(name, "fallthrough",
"__fallthrough__"))
fallthru(1);
Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.295 src/usr.bin/xlint/lint1/decl.c:1.296
--- src/usr.bin/xlint/lint1/decl.c:1.295 Fri Aug 26 19:44:19 2022
+++ src/usr.bin/xlint/lint1/decl.c Sun Aug 28 08:41:06 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.295 2022/08/26 19:44:19 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.296 2022/08/28 08:41:06 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.295 2022/08/26 19:44:19 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.296 2022/08/28 08:41:06 rillig Exp $");
#endif
#include <sys/param.h>
@@ -64,7 +64,7 @@ dinfo_t *dcs;
static type_t *tdeferr(type_t *, tspec_t);
static void settdsym(type_t *, sym_t *);
-static void align(unsigned int, unsigned int);
+static void dcs_align(unsigned int, unsigned int);
static sym_t *newtag(sym_t *, scl_t, bool, bool);
static bool eqargs(const type_t *, const type_t *, bool *);
static bool mnoarg(const type_t *, bool *);
@@ -224,7 +224,7 @@ is_incomplete(const type_t *tp)
* storage classes.
*/
void
-add_storage_class(scl_t sc)
+dcs_add_storage_class(scl_t sc)
{
if (sc == INLINE) {
@@ -249,7 +249,7 @@ add_storage_class(scl_t sc)
/*
* Remember the type, modifier or typedef name returned by the parser
* in *dcs (top element of decl stack). This information is used in
- * end_type() to build the type used for all declarators in this
+ * dcs_end_type to build the type used for all declarators in this
* declaration.
*
* If tp->t_typedef is 1, the type comes from a previously defined typename.
@@ -257,7 +257,7 @@ add_storage_class(scl_t sc)
* struct/union/enum tag.
*/
void
-add_type(type_t *tp)
+dcs_add_type(type_t *tp)
{
tspec_t t;
@@ -519,7 +519,7 @@ setpackedsize(type_t *tp)
}
void
-addpacked(void)
+dcs_add_packed(void)
{
if (dcs->d_type == NULL)
dcs->d_packed = true;
@@ -528,21 +528,21 @@ addpacked(void)
}
void
-add_attr_used(void)
+dcs_set_used(void)
{
dcs->d_used = true;
}
/*
* Remember a qualifier which is part of the declaration specifiers
- * (and not the declarator) in the top element of the declaration stack.
+ * (and not the declarator).
* Also detect multiple qualifiers of the same kind.
- * The remembered qualifier is used by end_type() to construct the type
+ * The remembered qualifier is used by dcs_end_type to construct the type
* for all declarators.
*/
void
-add_qualifier(tqual_t q)
+dcs_add_qualifier(tqual_t q)
{
if (q == CONST) {
@@ -661,13 +661,13 @@ end_declaration_level(void)
* There is no need to clear d_asm in dinfo structs with context AUTO,
* because these structs are freed at the end of the compound statement.
* But it must be cleared in the outermost dinfo struct, which has
- * context EXTERN. This could be done in begin_type() and would work for C90,
- * but not for C99 or C++ (due to mixed statements and declarations). Thus
- * we clear it in global_clean_up_decl(), which is used to do some cleanup
- * after global declarations/definitions.
+ * context EXTERN. This could be done in dcs_begin_type and would work for
+ * C90, but not for C99 or C++ (due to mixed statements and declarations).
+ * Thus we clear it in global_clean_up_decl(), which is used to do some
+ * cleanup after global declarations/definitions.
*/
void
-setasm(void)
+dcs_set_asm(void)
{
dinfo_t *di;
@@ -680,7 +680,7 @@ setasm(void)
* will be used by the next declaration
*/
void
-begin_type(void)
+dcs_begin_type(void)
{
dcs->d_abstract_type = NOTSPEC;
@@ -793,7 +793,7 @@ dcs_merge_declaration_specifiers(void)
* context.
*/
void
-end_type(void)
+dcs_end_type(void)
{
dcs_merge_declaration_specifiers();
@@ -1165,14 +1165,14 @@ declarator_1_struct_union(sym_t *dsym)
dcs->d_offset_in_bits = 0;
}
if (dsym->s_bitfield) {
- align(alignment_in_bits(tp), tp->t_flen);
+ dcs_align(alignment_in_bits(tp), tp->t_flen);
dsym->u.s_member.sm_offset_in_bits = dcs->d_offset_in_bits -
dcs->d_offset_in_bits % size_in_bits(t);
tp->t_foffs = dcs->d_offset_in_bits -
dsym->u.s_member.sm_offset_in_bits;
dcs->d_offset_in_bits += tp->t_flen;
} else {
- align(alignment_in_bits(tp), 0);
+ dcs_align(alignment_in_bits(tp), 0);
dsym->u.s_member.sm_offset_in_bits = dcs->d_offset_in_bits;
dcs->d_offset_in_bits += sz;
}
@@ -1198,7 +1198,7 @@ declarator_1_struct_union(sym_t *dsym)
* al contains the required alignment, len the length of a bit-field.
*/
static void
-align(unsigned int al, unsigned int len)
+dcs_align(unsigned int al, unsigned int len)
{
unsigned int no;
@@ -1293,7 +1293,7 @@ block_derive_pointer(type_t *stp, bool i
* The following 3 functions extend the type of a declarator with
* pointer, function and array types.
*
- * The current type is the type built by end_type() (dcs->d_type) and
+ * The current type is the type built by dcs_end_type (dcs->d_type) and
* pointer, function and array types already added for this
* declarator. The new type extension is inserted between both.
*/
@@ -1843,7 +1843,7 @@ complete_tag_struct_or_union(type_t *tp,
tp->t_str->sou_incomplete = false;
t = tp->t_tspec;
- align((u_int)dcs->d_sou_align_in_bits, 0);
+ dcs_align((u_int)dcs->d_sou_align_in_bits, 0);
sp = tp->t_str;
sp->sou_align_in_bits = dcs->d_sou_align_in_bits;
sp->sou_first_member = fmem;
Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.165 src/usr.bin/xlint/lint1/externs1.h:1.166
--- src/usr.bin/xlint/lint1/externs1.h:1.165 Tue Jul 5 22:50:41 2022
+++ src/usr.bin/xlint/lint1/externs1.h Sun Aug 28 08:41:06 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: externs1.h,v 1.165 2022/07/05 22:50:41 rillig Exp $ */
+/* $NetBSD: externs1.h,v 1.166 2022/08/28 08:41:06 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -189,16 +189,16 @@ extern type_t *block_dup_type(const type
extern type_t *expr_dup_type(const type_t *);
extern type_t *expr_unqualified_type(const type_t *);
extern bool is_incomplete(const type_t *);
-extern void add_storage_class(scl_t);
-extern void add_type(type_t *);
-extern void add_qualifier(tqual_t);
-extern void addpacked(void);
-extern void add_attr_used(void);
+extern void dcs_add_storage_class(scl_t);
+extern void dcs_add_type(type_t *);
+extern void dcs_add_qualifier(tqual_t);
+extern void dcs_add_packed(void);
+extern void dcs_set_used(void);
extern void begin_declaration_level(declaration_kind);
extern void end_declaration_level(void);
-extern void setasm(void);
-extern void begin_type(void);
-extern void end_type(void);
+extern void dcs_set_asm(void);
+extern void dcs_begin_type(void);
+extern void dcs_end_type(void);
extern int length_in_bits(const type_t *, const char *);
extern unsigned int alignment_in_bits(const type_t *);
extern sym_t *lnklst(sym_t *, sym_t *);
Index: src/usr.bin/xlint/lint1/lint1.h
diff -u src/usr.bin/xlint/lint1/lint1.h:1.156 src/usr.bin/xlint/lint1/lint1.h:1.157
--- src/usr.bin/xlint/lint1/lint1.h:1.156 Tue Jul 5 22:50:41 2022
+++ src/usr.bin/xlint/lint1/lint1.h Sun Aug 28 08:41:06 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.156 2022/07/05 22:50:41 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.157 2022/08/28 08:41:06 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -346,7 +346,7 @@ typedef struct dinfo {
tspec_t d_sign_mod; /* SIGNED or UNSIGN */
tspec_t d_rank_mod; /* SHORT, LONG or QUAD */
scl_t d_scl; /* storage class */
- type_t *d_type; /* after end_type() pointer to the type used
+ type_t *d_type; /* after dcs_end_type pointer to the type used
for all declarators */
sym_t *d_redeclared_symbol;
unsigned int d_offset_in_bits; /* offset of next structure member */
@@ -355,7 +355,7 @@ typedef struct dinfo {
bool d_const:1; /* const in declaration specifiers */
bool d_volatile:1; /* volatile in declaration specifiers */
bool d_inline:1; /* inline in declaration specifiers */
- bool d_multiple_storage_classes:1; /* reported in end_type */
+ bool d_multiple_storage_classes:1; /* reported in dcs_end_type */
bool d_invalid_type_combination:1;
bool d_nonempty_decl:1; /* if at least one tag is declared
* ... in the current function decl. */