aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
-rw-r--r--parse.c9
-rw-r--r--symbol.c3
-rw-r--r--validation/bitfield-sizes.c10
3 files changed, 10 insertions, 12 deletions
diff --git a/parse.c b/parse.c
index efd8c5de..fb05253b 100644
--- a/parse.c
+++ b/parse.c
@@ -1946,12 +1946,9 @@ static struct token *handle_bitfield(struct token *token, struct decl_state *ctx
width = const_expression_value(expr);
bitfield->bit_size = width;
- if (width < 0 || width > INT_MAX) {
- sparse_error(token->pos, "invalid bitfield width, %lld.", width);
- width = -1;
- } else if (*ctx->ident && width == 0) {
- sparse_error(token->pos, "invalid named zero-width bitfield `%s'",
- show_ident(*ctx->ident));
+ if (width < 0 || width > INT_MAX || (*ctx->ident && width == 0)) {
+ sparse_error(token->pos, "bitfield '%s' has invalid width (%lld)",
+ show_ident(*ctx->ident), width);
width = -1;
} else if (*ctx->ident) {
struct symbol *base_type = bitfield->ctype.base_type;
diff --git a/symbol.c b/symbol.c
index 40e50874..3655cbb7 100644
--- a/symbol.c
+++ b/symbol.c
@@ -259,7 +259,8 @@ static struct symbol *examine_bitfield_type(struct symbol *sym)
if (!base_type)
return sym;
if (sym->bit_size > base_type->bit_size) {
- sparse_error(sym->pos, "impossible field-width, %d, for this type", sym->bit_size);
+ sparse_error(sym->pos, "bitfield '%s' is wider (%d) than its type (%s)",
+ show_ident(sym->ident), sym->bit_size, show_typename(base_type));
sym->bit_size = -1;
}
diff --git a/validation/bitfield-sizes.c b/validation/bitfield-sizes.c
index c43bb0a4..9f76d074 100644
--- a/validation/bitfield-sizes.c
+++ b/validation/bitfield-sizes.c
@@ -21,10 +21,10 @@ static struct b b;
* check-command: sparse -m64 $file
*
* check-error-start
-bitfield-sizes.c:12:18: error: invalid bitfield width, -1.
-bitfield-sizes.c:13:26: error: invalid bitfield width, 2147483648.
-bitfield-sizes.c:15:17: error: invalid named zero-width bitfield `a0'
-bitfield-sizes.c:6:15: error: impossible field-width, 33, for this type
-bitfield-sizes.c:7:15: error: impossible field-width, 65, for this type
+bitfield-sizes.c:12:18: error: bitfield 'm1' has invalid width (-1)
+bitfield-sizes.c:13:26: error: bitfield 'x1' has invalid width (2147483648)
+bitfield-sizes.c:15:17: error: bitfield 'a0' has invalid width (0)
+bitfield-sizes.c:6:15: error: bitfield 'x' is wider (33) than its type (int)
+bitfield-sizes.c:7:15: error: bitfield 'y' is wider (65) than its type (long)
* check-error-end
*/