diff options
| -rw-r--r-- | tests/usr.bin/xlint/lint1/d_alignof.c | 4 | ||||
| -rw-r--r-- | usr.bin/xlint/lint1/tree.c | 49 |
2 files changed, 20 insertions, 33 deletions
diff --git a/tests/usr.bin/xlint/lint1/d_alignof.c b/tests/usr.bin/xlint/lint1/d_alignof.c index f278a44c81b..165cf572d2d 100644 --- a/tests/usr.bin/xlint/lint1/d_alignof.c +++ b/tests/usr.bin/xlint/lint1/d_alignof.c @@ -1,4 +1,4 @@ -/* $NetBSD: d_alignof.c,v 1.9 2023/06/30 09:21:52 rillig Exp $ */ +/* $NetBSD: d_alignof.c,v 1.10 2023/06/30 09:26:03 rillig Exp $ */ # 3 "d_alignof.c" /* https://gcc.gnu.org/onlinedocs/gcc/Alignment.html */ @@ -105,7 +105,7 @@ alignof_variants(void) /* expect+1: warning: enum 'incomplete_enum' never defined [235] */ enum incomplete_enum; - /* expect+1: error: negative array dimension (-4) [20] */ + /* expect+1: error: cannot take size/alignment of incomplete type [143] */ typedef int incomplete_enum[-(int)__alignof(enum incomplete_enum)]; struct bit_fields { diff --git a/usr.bin/xlint/lint1/tree.c b/usr.bin/xlint/lint1/tree.c index 68883a855ab..1d7749b93e7 100644 --- a/usr.bin/xlint/lint1/tree.c +++ b/usr.bin/xlint/lint1/tree.c @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.534 2023/06/30 08:48:38 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.535 2023/06/30 09:26:03 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.534 2023/06/30 08:48:38 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.535 2023/06/30 09:26:03 rillig Exp $"); #endif #include <float.h> @@ -4095,39 +4095,26 @@ type_size_in_bits(const type_t *tp) tnode_t * build_alignof(const type_t *tp) { - switch (tp->t_tspec) { - case ARRAY: - break; - - case FUNC: + if (tp->t_tspec == FUNC) { /* cannot take size/alignment of function type '%s' */ error(144, type_name(tp)); return NULL; - - case STRUCT: - case UNION: - if (is_incomplete(tp)) { - /* cannot take size/alignment of incomplete type */ - error(143); - return NULL; - } - break; - case ENUM: - break; - default: - if (tp->t_bitfield) { - /* cannot take size/alignment of bit-field */ - error(145); - return NULL; - } - if (tp->t_tspec == VOID) { - /* cannot take size/alignment of void */ - error(146); - return NULL; - } - break; } - + if (tp->t_tspec == VOID) { + /* cannot take size/alignment of void */ + error(146); + return NULL; + } + if (is_incomplete(tp)) { + /* cannot take size/alignment of incomplete type */ + error(143); + return NULL; + } + if (tp->t_bitfield) { + /* cannot take size/alignment of bit-field */ + error(145); + return NULL; + } return build_integer_constant(SIZEOF_TSPEC, (int64_t)alignment_in_bits(tp) / CHAR_SIZE); } |
