Module Name: src Committed By: rillig Date: Sat Apr 2 17:28:06 UTC 2022
Modified Files: src/usr.bin/xlint/lint1: decl.c externs1.h Log Message: lint: inline setcomplete No functional change. To generate a diff of this commit: cvs rdiff -u -r1.261 -r1.262 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.151 -r1.152 src/usr.bin/xlint/lint1/externs1.h 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/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.261 src/usr.bin/xlint/lint1/decl.c:1.262 --- src/usr.bin/xlint/lint1/decl.c:1.261 Sat Apr 2 16:27:03 2022 +++ src/usr.bin/xlint/lint1/decl.c Sat Apr 2 17:28:06 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.261 2022/04/02 16:27:03 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.262 2022/04/02 17:28:06 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.261 2022/04/02 16:27:03 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.262 2022/04/02 17:28:06 rillig Exp $"); #endif #include <sys/param.h> @@ -225,25 +225,6 @@ is_incomplete(const type_t *tp) } /* - * Mark an array, struct, union or enum type as complete or incomplete. - */ -void -setcomplete(type_t *tp, bool complete) -{ - tspec_t t; - - lint_assert(tp != NULL); - if ((t = tp->t_tspec) == ARRAY) { - tp->t_incomplete_array = !complete; - } else if (t == STRUCT || t == UNION) { - tp->t_str->sou_incomplete = !complete; - } else { - lint_assert(t == ENUM); - tp->t_enum->en_incomplete = !complete; - } -} - -/* * Remember the storage class of the current declaration in dcs->d_scl * (the top element of the declaration stack) and detect multiple * storage classes. @@ -1365,7 +1346,7 @@ add_array(sym_t *decl, bool dim, int n) /* zero sized array is a C99 extension */ c99ism(322); } else if (n == 0 && !dim) { - setcomplete(tp, false); + tp->t_incomplete_array = true; } debug_step("add_array: '%s'", type_name(decl->s_type)); @@ -1707,12 +1688,13 @@ mktag(sym_t *tag, tspec_t kind, bool dec 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; } else { tp->t_is_enum = true; tp->t_enum = block_zero_alloc(sizeof(*tp->t_enum)); tp->t_enum->en_tag = tag; + tp->t_enum->en_incomplete = true; } - setcomplete(tp, false); } return tp; } @@ -1807,7 +1789,10 @@ complete_tag_struct_or_union(type_t *tp, if (tp == NULL) /* in case of syntax errors */ return gettyp(INT); - setcomplete(tp, true); + if (tp->t_tspec == ENUM) + tp->t_enum->en_incomplete = false; + else + tp->t_str->sou_incomplete = false; t = tp->t_tspec; align((u_int)dcs->d_sou_align_in_bits, 0); @@ -1852,7 +1837,7 @@ type_t * complete_tag_enum(type_t *tp, sym_t *fmem) { - setcomplete(tp, true); + tp->t_enum->en_incomplete = false; tp->t_enum->en_first_enumerator = fmem; return tp; } @@ -2388,7 +2373,7 @@ complete_type(sym_t *dsym, sym_t *ssym) if (dst->t_dim == 0 && src->t_dim != 0) { *dstp = dst = block_dup_type(dst); dst->t_dim = src->t_dim; - setcomplete(dst, true); + dst->t_incomplete_array = false; } } else if (dst->t_tspec == FUNC) { if (!dst->t_proto && src->t_proto) { Index: src/usr.bin/xlint/lint1/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.151 src/usr.bin/xlint/lint1/externs1.h:1.152 --- src/usr.bin/xlint/lint1/externs1.h:1.151 Sat Apr 2 12:24:55 2022 +++ src/usr.bin/xlint/lint1/externs1.h Sat Apr 2 17:28:06 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.151 2022/04/02 12:24:55 rillig Exp $ */ +/* $NetBSD: externs1.h,v 1.152 2022/04/02 17:28:06 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -181,7 +181,6 @@ 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 setcomplete(type_t *, bool); extern void add_storage_class(scl_t); extern void add_type(type_t *); extern void add_qualifier(tqual_t);