Module Name: src Committed By: rillig Date: Sat Apr 22 17:49:15 UTC 2023
Modified Files: src/usr.bin/xlint/common: tyname.c src/usr.bin/xlint/lint1: cgram.y debug.c decl.c emit1.c init.c lint1.h tree.c Log Message: lint: rename type_t.t_str to t_sou The name 't_str' could have meant 'string' or 'struct'. Since both struct and union types have members, rename it to 't_sou'. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/usr.bin/xlint/common/tyname.c cvs rdiff -u -r1.434 -r1.435 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.28 -r1.29 src/usr.bin/xlint/lint1/debug.c cvs rdiff -u -r1.307 -r1.308 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.65 -r1.66 src/usr.bin/xlint/lint1/emit1.c cvs rdiff -u -r1.240 -r1.241 src/usr.bin/xlint/lint1/init.c cvs rdiff -u -r1.163 -r1.164 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.516 -r1.517 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/common/tyname.c diff -u src/usr.bin/xlint/common/tyname.c:1.54 src/usr.bin/xlint/common/tyname.c:1.55 --- src/usr.bin/xlint/common/tyname.c:1.54 Sat Feb 18 15:14:11 2023 +++ src/usr.bin/xlint/common/tyname.c Sat Apr 22 17:49:14 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: tyname.c,v 1.54 2023/02/18 15:14:11 rillig Exp $ */ +/* $NetBSD: tyname.c,v 1.55 2023/04/22 17:49:14 rillig Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) -__RCSID("$NetBSD: tyname.c,v 1.54 2023/02/18 15:14:11 rillig Exp $"); +__RCSID("$NetBSD: tyname.c,v 1.55 2023/04/22 17:49:14 rillig Exp $"); #endif #include <assert.h> @@ -189,12 +189,12 @@ type_name_of_struct_or_union(buffer *buf { buf_add(buf, " "); #ifdef IS_LINT1 - if (tp->t_str->sou_tag->s_name == unnamed && - tp->t_str->sou_first_typedef != NULL) { + if (tp->t_sou->sou_tag->s_name == unnamed && + tp->t_sou->sou_first_typedef != NULL) { buf_add(buf, "typedef "); - buf_add(buf, tp->t_str->sou_first_typedef->s_name); + buf_add(buf, tp->t_sou->sou_first_typedef->s_name); } else { - buf_add(buf, tp->t_str->sou_tag->s_name); + buf_add(buf, tp->t_sou->sou_tag->s_name); } #else buf_add(buf, tp->t_isuniqpos ? "*anonymous*" : tp->t_tag->h_name); @@ -255,7 +255,7 @@ type_name(const type_t *tp) buf_add(&buf, "volatile "); #ifdef IS_LINT1 - if (is_struct_or_union(t) && tp->t_str->sou_incomplete) + if (is_struct_or_union(t) && tp->t_sou->sou_incomplete) buf_add(&buf, "incomplete "); #endif buf_add(&buf, tspec_name(t)); Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.434 src/usr.bin/xlint/lint1/cgram.y:1.435 --- src/usr.bin/xlint/lint1/cgram.y:1.434 Sun Apr 2 19:47:54 2023 +++ src/usr.bin/xlint/lint1/cgram.y Sat Apr 22 17:49:15 2023 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.434 2023/04/02 19:47:54 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.435 2023/04/22 17:49:15 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.434 2023/04/02 19:47:54 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.435 2023/04/22 17:49:15 rillig Exp $"); #endif #include <limits.h> @@ -968,7 +968,7 @@ struct_declaration: /* C99 6.7.2.1 */ /* anonymous struct/union members is a C11 feature */ warning(49); if (is_struct_or_union(dcs->d_type->t_tspec)) { - $$ = dcs->d_type->t_str->sou_first_member; + $$ = dcs->d_type->t_sou->sou_first_member; /* add all the members of the anonymous struct/union */ anonymize($$); } else { Index: src/usr.bin/xlint/lint1/debug.c diff -u src/usr.bin/xlint/lint1/debug.c:1.28 src/usr.bin/xlint/lint1/debug.c:1.29 --- src/usr.bin/xlint/lint1/debug.c:1.28 Tue Apr 11 17:52:11 2023 +++ src/usr.bin/xlint/lint1/debug.c Sat Apr 22 17:49:15 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.28 2023/04/11 17:52:11 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.29 2023/04/22 17:49:15 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) -__RCSID("$NetBSD: debug.c,v 1.28 2023/04/11 17:52:11 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.29 2023/04/22 17:49:15 rillig Exp $"); #endif #include <stdlib.h> @@ -112,7 +112,7 @@ debug_type_details(const type_t *tp) if (is_struct_or_union(tp->t_tspec)) { debug_indent_inc(); - for (const sym_t *mem = tp->t_str->sou_first_member; + for (const sym_t *mem = tp->t_sou->sou_first_member; mem != NULL; mem = mem->s_next) { debug_sym("", mem, "\n"); debug_type_details(mem->s_type); Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.307 src/usr.bin/xlint/lint1/decl.c:1.308 --- src/usr.bin/xlint/lint1/decl.c:1.307 Tue Mar 28 20:04:52 2023 +++ src/usr.bin/xlint/lint1/decl.c Sat Apr 22 17:49:15 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.307 2023/03/28 20:04:52 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.308 2023/04/22 17:49:15 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.307 2023/03/28 20:04:52 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.308 2023/04/22 17:49:15 rillig Exp $"); #endif #include <sys/param.h> @@ -191,7 +191,7 @@ expr_unqualified_type(const type_t *tp) * qualifiers as well, but that would require a deep copy of the * struct or union type. This in turn would defeat the type * comparison in types_compatible, which simply tests whether - * tp1->t_str == tp2->t_str. + * tp1->t_sou == tp2->t_sou. */ return ntp; @@ -211,7 +211,7 @@ is_incomplete(const type_t *tp) if (t == ARRAY) return tp->t_incomplete_array; if (is_struct_or_union(t)) - return tp->t_str->sou_incomplete; + return tp->t_sou->sou_incomplete; if (t == ENUM) return tp->t_enum->en_incomplete; @@ -467,8 +467,8 @@ set_first_typedef(type_t *tp, sym_t *sym tspec_t t; if (is_struct_or_union(t = tp->t_tspec)) { - if (tp->t_str->sou_first_typedef == NULL) - tp->t_str->sou_first_typedef = sym; + if (tp->t_sou->sou_first_typedef == NULL) + tp->t_sou->sou_first_typedef = sym; } else if (t == ENUM) { if (tp->t_enum->en_first_typedef == NULL) tp->t_enum->en_first_typedef = sym; @@ -495,7 +495,7 @@ set_packed_size(type_t *tp) switch (tp->t_tspec) { case STRUCT: case UNION: - sp = tp->t_str; + sp = tp->t_sou; sp->sou_size_in_bits = 0; for (mem = sp->sou_first_member; mem != NULL; mem = mem->s_next) { @@ -859,7 +859,7 @@ length_in_bits(const type_t *tp, const c /* '%s' has incomplete type '%s' */ error(31, name, type_name(tp)); } - elsz = tp->t_str->sou_size_in_bits; + elsz = tp->t_sou->sou_size_in_bits; break; case ENUM: if (is_incomplete(tp) && name != NULL) { @@ -896,7 +896,7 @@ alignment_in_bits(const type_t *tp) tp = tp->t_subt; if (is_struct_or_union(t = tp->t_tspec)) - a = tp->t_str->sou_align_in_bits; + a = tp->t_sou->sou_align_in_bits; else { lint_assert(t != FUNC); if ((a = size_in_bits(t)) == 0) @@ -1557,7 +1557,7 @@ declarator_name(sym_t *sym) case DK_STRUCT_MEMBER: case DK_UNION_MEMBER: /* Set parent */ - sym->u.s_member.sm_sou_type = dcs->d_tagtyp->t_str; + sym->u.s_member.sm_sou_type = dcs->d_tagtyp->t_sou; sym->s_def = DEF; /* XXX: Where is sym->u.s_member.sm_offset_in_bits set? */ sc = dcs->d_kind == DK_STRUCT_MEMBER @@ -1717,10 +1717,10 @@ make_tag_type(sym_t *tag, tspec_t kind, if (tp->t_tspec == NOTSPEC) { tp->t_tspec = kind; if (kind != ENUM) { - tp->t_str = block_zero_alloc(sizeof(*tp->t_str)); - tp->t_str->sou_align_in_bits = CHAR_SIZE; - tp->t_str->sou_tag = tag; - tp->t_str->sou_incomplete = true; + tp->t_sou = block_zero_alloc(sizeof(*tp->t_sou)); + tp->t_sou->sou_align_in_bits = CHAR_SIZE; + tp->t_sou->sou_tag = tag; + tp->t_sou->sou_incomplete = true; } else { tp->t_is_enum = true; tp->t_enum = block_zero_alloc(sizeof(*tp->t_enum)); @@ -1821,12 +1821,12 @@ complete_tag_struct_or_union(type_t *tp, if (tp->t_tspec == ENUM) tp->t_enum->en_incomplete = false; else - tp->t_str->sou_incomplete = false; + tp->t_sou->sou_incomplete = false; tspec_t t = tp->t_tspec; dcs_align((u_int)dcs->d_sou_align_in_bits, 0); - struct_or_union *sp = tp->t_str; + struct_or_union *sp = tp->t_sou; sp->sou_align_in_bits = dcs->d_sou_align_in_bits; sp->sou_first_member = fmem; if (tp->t_packed) @@ -2228,7 +2228,7 @@ types_compatible(const type_t *tp1, cons return false; if (is_struct_or_union(t)) - return tp1->t_str == tp2->t_str; + return tp1->t_sou == tp2->t_sou; if (t == ENUM && eflag) return tp1->t_enum == tp2->t_enum; Index: src/usr.bin/xlint/lint1/emit1.c diff -u src/usr.bin/xlint/lint1/emit1.c:1.65 src/usr.bin/xlint/lint1/emit1.c:1.66 --- src/usr.bin/xlint/lint1/emit1.c:1.65 Thu Feb 2 22:23:30 2023 +++ src/usr.bin/xlint/lint1/emit1.c Sat Apr 22 17:49:15 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: emit1.c,v 1.65 2023/02/02 22:23:30 rillig Exp $ */ +/* $NetBSD: emit1.c,v 1.66 2023/04/22 17:49:15 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) -__RCSID("$NetBSD: emit1.c,v 1.65 2023/02/02 22:23:30 rillig Exp $"); +__RCSID("$NetBSD: emit1.c,v 1.66 2023/04/22 17:49:15 rillig Exp $"); #endif #include "lint1.h" @@ -121,7 +121,7 @@ outtype(const type_t *tp) } else if (ts == ENUM) { outtt(tp->t_enum->en_tag, tp->t_enum->en_first_typedef); } else if (is_struct_or_union(ts)) { - outtt(tp->t_str->sou_tag, tp->t_str->sou_first_typedef); + outtt(tp->t_sou->sou_tag, tp->t_sou->sou_first_typedef); } else if (ts == FUNC && tp->t_proto) { na = 0; for (arg = tp->t_args; arg != NULL; arg = arg->s_next) Index: src/usr.bin/xlint/lint1/init.c diff -u src/usr.bin/xlint/lint1/init.c:1.240 src/usr.bin/xlint/lint1/init.c:1.241 --- src/usr.bin/xlint/lint1/init.c:1.240 Mon Feb 6 21:01:55 2023 +++ src/usr.bin/xlint/lint1/init.c Sat Apr 22 17:49:15 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: init.c,v 1.240 2023/02/06 21:01:55 rillig Exp $ */ +/* $NetBSD: init.c,v 1.241 2023/04/22 17:49:15 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) -__RCSID("$NetBSD: init.c,v 1.240 2023/02/06 21:01:55 rillig Exp $"); +__RCSID("$NetBSD: init.c,v 1.241 2023/04/22 17:49:15 rillig Exp $"); #endif #include <stdlib.h> @@ -224,7 +224,7 @@ first_named_member(const type_t *tp) { lint_assert(is_struct_or_union(tp->t_tspec)); - return skip_unnamed(tp->t_str->sou_first_member); + return skip_unnamed(tp->t_sou->sou_first_member); } static const sym_t * @@ -233,7 +233,7 @@ look_up_member(const type_t *tp, const c const sym_t *m; lint_assert(is_struct_or_union(tp->t_tspec)); - for (m = tp->t_str->sou_first_member; m != NULL; m = m->s_next) + for (m = tp->t_sou->sou_first_member; m != NULL; m = m->s_next) if (strcmp(m->s_name, name) == 0) return m; return NULL; @@ -764,7 +764,7 @@ initialization_lbrace(initialization *in warning(238); } - if (is_struct_or_union(tp->t_tspec) && tp->t_str->sou_incomplete) { + if (is_struct_or_union(tp->t_tspec) && tp->t_sou->sou_incomplete) { /* initialization of incomplete type '%s' */ error(175, type_name(tp)); in->in_err = true; Index: src/usr.bin/xlint/lint1/lint1.h diff -u src/usr.bin/xlint/lint1/lint1.h:1.163 src/usr.bin/xlint/lint1/lint1.h:1.164 --- src/usr.bin/xlint/lint1/lint1.h:1.163 Tue Feb 21 19:30:51 2023 +++ src/usr.bin/xlint/lint1/lint1.h Sat Apr 22 17:49:15 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lint1.h,v 1.163 2023/02/21 19:30:51 rillig Exp $ */ +/* $NetBSD: lint1.h,v 1.164 2023/04/22 17:49:15 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -149,7 +149,7 @@ typedef struct { /* * The type of an expression or object. Complex types are formed via t_subt - * (for arrays, pointers and functions), as well as t_str. + * (for arrays, pointers and functions), as well as t_sou. */ struct lint1_type { tspec_t t_tspec; /* type specifier */ @@ -174,7 +174,7 @@ struct lint1_type { bool t_packed:1; union { int _t_dim; /* dimension (if ARRAY) */ - struct_or_union *_t_str; + struct_or_union *_t_sou; enumeration *_t_enum; struct sym *_t_args; /* arguments (if t_proto) */ } t_u; @@ -188,8 +188,7 @@ struct lint1_type { }; #define t_dim t_u._t_dim -/* TODO: rename t_str to t_sou, to avoid confusing it with strings. */ -#define t_str t_u._t_str +#define t_sou t_u._t_sou #define t_enum t_u._t_enum #define t_args t_u._t_args #define t_flen t_b._t_flen @@ -262,7 +261,7 @@ typedef struct sym { bool s_bool_constant; int s_enum_constant; /* XXX: should be TARG_INT */ struct { - /* XXX: what is the difference to s_type->t_str? */ + /* XXX: what is the difference to s_type->t_sou? */ struct_or_union *sm_sou_type; unsigned int sm_offset_in_bits; } s_member; Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.516 src/usr.bin/xlint/lint1/tree.c:1.517 --- src/usr.bin/xlint/lint1/tree.c:1.516 Sat Apr 22 17:42:29 2023 +++ src/usr.bin/xlint/lint1/tree.c Sat Apr 22 17:49:15 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.516 2023/04/22 17:42:29 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.517 2023/04/22 17:49:15 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.516 2023/04/22 17:42:29 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.517 2023/04/22 17:49:15 rillig Exp $"); #endif #include <float.h> @@ -981,7 +981,7 @@ subt_size_in_bytes(type_t *tp) break; case STRUCT: case UNION: - if ((elsz_in_bits = tp->t_str->sou_size_in_bits) == 0) + if ((elsz_in_bits = tp->t_sou->sou_size_in_bits) == 0) /* cannot do pointer arithmetic on operand of ... */ error(136); break; @@ -1207,7 +1207,7 @@ build_colon(bool sys, tnode_t *ln, tnode } else if (is_struct_or_union(lt)) { /* Both types must be identical. */ lint_assert(is_struct_or_union(rt)); - lint_assert(ln->tn_type->t_str == rn->tn_type->t_str); + lint_assert(ln->tn_type->t_sou == rn->tn_type->t_sou); if (is_incomplete(ln->tn_type)) { /* unknown operand size, op '%s' */ error(138, op_name(COLON)); @@ -1311,7 +1311,7 @@ build_assignment(op_t op, bool sys, tnod if ((op == ASSIGN || op == RETURN || op == INIT) && (lt == STRUCT || rt == STRUCT)) { lint_assert(lt == rt); - lint_assert(ln->tn_type->t_str == rn->tn_type->t_str); + lint_assert(ln->tn_type->t_sou == rn->tn_type->t_sou); if (is_incomplete(ln->tn_type)) { if (op == RETURN) { /* cannot return incomplete type */ @@ -1887,11 +1887,11 @@ struct_or_union_member(tnode_t *tn, op_t t = (tp = tn->tn_type)->t_tspec; if (op == POINT) { if (is_struct_or_union(t)) - str = tp->t_str; + str = tp->t_sou; } else if (op == ARROW && t == PTR) { t = (tp = tp->t_subt)->t_tspec; if (is_struct_or_union(t)) - str = tp->t_str; + str = tp->t_sou; } /* @@ -2443,9 +2443,9 @@ typeok_colon(const mod_t *mp, if (lt == BOOL && rt == BOOL) return true; - if (lt == STRUCT && rt == STRUCT && ltp->t_str == rtp->t_str) + if (lt == STRUCT && rt == STRUCT && ltp->t_sou == rtp->t_sou) return true; - if (lt == UNION && rt == UNION && ltp->t_str == rtp->t_str) + if (lt == UNION && rt == UNION && ltp->t_sou == rtp->t_sou) return true; if (lt == PTR && is_null_pointer(rn)) @@ -2488,7 +2488,7 @@ has_constant_member(const type_t *tp) { lint_assert(is_struct_or_union(tp->t_tspec)); - for (sym_t *m = tp->t_str->sou_first_member; + for (sym_t *m = tp->t_sou->sou_first_member; m != NULL; m = m->s_next) { const type_t *mtp = m->s_type; if (mtp->t_const) @@ -2844,7 +2844,7 @@ check_assign_types_compatible(op_t op, i if (is_struct_or_union(lt) && is_struct_or_union(rt)) /* both are struct or union */ - return ltp->t_str == rtp->t_str; + return ltp->t_sou == rtp->t_sou; /* a null pointer may be assigned to any pointer */ if (lt == PTR && is_null_pointer(rn)) @@ -3437,8 +3437,8 @@ static bool struct_starts_with(const type_t *struct_tp, const type_t *member_tp) { - return struct_tp->t_str->sou_first_member != NULL && - types_compatible(struct_tp->t_str->sou_first_member->s_type, + return struct_tp->t_sou->sou_first_member != NULL && + types_compatible(struct_tp->t_sou->sou_first_member->s_type, member_tp, true, false, NULL); } @@ -3477,8 +3477,8 @@ should_warn_about_pointer_cast(const typ if (nst == STRUCT && ost == STRUCT) { debug_type(nstp); debug_type(ostp); - const sym_t *nmem = nstp->t_str->sou_first_member; - const sym_t *omem = ostp->t_str->sou_first_member; + const sym_t *nmem = nstp->t_sou->sou_first_member; + const sym_t *omem = ostp->t_sou->sou_first_member; while (nmem != NULL && omem != NULL && types_compatible(nmem->s_type, omem->s_type, true, false, NULL)) @@ -3494,7 +3494,7 @@ should_warn_about_pointer_cast(const typ if (nst == UNION || ost == UNION) { const type_t *union_tp = nst == UNION ? nstp : ostp; const type_t *other_tp = nst == UNION ? ostp : nstp; - for (const sym_t *mem = union_tp->t_str->sou_first_member; + for (const sym_t *mem = union_tp->t_sou->sou_first_member; mem != NULL; mem = mem->s_next) { if (types_compatible(mem->s_type, other_tp, true, false, NULL)) @@ -3502,7 +3502,7 @@ should_warn_about_pointer_cast(const typ } } - if (is_struct_or_union(nst) && nstp->t_str != ostp->t_str) + if (is_struct_or_union(nst) && nstp->t_sou != ostp->t_sou) return true; return portable_size_in_bits(nst) != portable_size_in_bits(ost); @@ -3980,7 +3980,7 @@ type_size_in_bits(const type_t *tp) error(143); elsz = 1; } else { - elsz = tp->t_str->sou_size_in_bits; + elsz = tp->t_sou->sou_size_in_bits; } break; case ENUM: @@ -4058,7 +4058,7 @@ cast_to_union(const tnode_t *otn, type_t return NULL; } - for (const sym_t *m = ntp->t_str->sou_first_member; + for (const sym_t *m = ntp->t_sou->sou_first_member; m != NULL; m = m->s_next) { if (types_compatible(m->s_type, otn->tn_type, false, false, NULL)) {