diff --git a/usr.bin/xlint/lint1/decl.c b/usr.bin/xlint/lint1/decl.c index 28fbeee6faf3..214b2b5793f5 100644 --- a/usr.bin/xlint/lint1/decl.c +++ b/usr.bin/xlint/lint1/decl.c @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.331 2023/07/01 09:31:55 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.332 2023/07/01 10:04:27 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: decl.c,v 1.331 2023/07/01 09:31:55 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.332 2023/07/01 10:04:27 rillig Exp $"); #endif #include @@ -424,7 +424,7 @@ set_first_typedef(type_t *tp, sym_t *sym) } static unsigned int -bit_fields_width(sym_t **mem, bool *named) +bit_fields_width(const sym_t **mem, bool *named) { unsigned int width = 0; unsigned int align = 0; @@ -452,7 +452,7 @@ pack_struct_or_union(type_t *tp) unsigned int bits = 0; bool named = false; - for (sym_t *mem = tp->t_sou->sou_first_member; + for (const sym_t *mem = tp->t_sou->sou_first_member; mem != NULL; mem = mem->s_next) { // TODO: Maybe update mem->u.s_member.sm_offset_in_bits. if (mem->s_type->t_bitfield) { diff --git a/usr.bin/xlint/lint1/tree.c b/usr.bin/xlint/lint1/tree.c index d58762a1b1eb..292e2ff2284a 100644 --- a/usr.bin/xlint/lint1/tree.c +++ b/usr.bin/xlint/lint1/tree.c @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.541 2023/07/01 09:31:55 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.542 2023/07/01 10:04:27 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: tree.c,v 1.541 2023/07/01 09:31:55 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.542 2023/07/01 10:04:27 rillig Exp $"); #endif #include @@ -4014,6 +4014,11 @@ type_size_in_bits(const type_t *tp) unsigned int elsz; switch (tp->t_tspec) { + case VOID: + /* cannot take size/alignment of void */ + error(146); + elsz = 1; + break; case FUNC: /* cannot take size/alignment of function type '%s' */ error(144, type_name(tp)); @@ -4040,14 +4045,8 @@ type_size_in_bits(const type_t *tp) /* cannot take size/alignment of bit-field */ error(145); } - if (tp->t_tspec == VOID) { - /* cannot take size/alignment of void */ - error(146); - elsz = 1; - } else { - elsz = size_in_bits(tp->t_tspec); - lint_assert(elsz > 0); - } + elsz = size_in_bits(tp->t_tspec); + lint_assert(elsz > 0); break; }