aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-10-01 22:50:07 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-11-30 14:05:03 +0100
commit63d2c3d5f7c6e3684f164a6959ceb5986595ba42 (patch)
tree111166748fcc1d89072ef9c8cf3016e2d53ef825
parent4ce42ee56d9207ef831f76104fa248fa0fddb326 (diff)
downloadsparse-63d2c3d5f7c6e3684f164a6959ceb5986595ba42.tar.gz
bitfield: oversized bitfields are errors
Till now, a bitfield with a width bigger than its base type only caused a warning but this should be considered as an error since it's generally impossible to emit correct IR code for it. Fix this by issuing an error instead and marking the width as invalid. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--symbol.c6
-rw-r--r--validation/bitfield-sizes.c1
2 files changed, 4 insertions, 3 deletions
diff --git a/symbol.c b/symbol.c
index 6c1fb2a5..40e50874 100644
--- a/symbol.c
+++ b/symbol.c
@@ -258,8 +258,10 @@ static struct symbol *examine_bitfield_type(struct symbol *sym)
if (!base_type)
return sym;
- if (sym->bit_size > base_type->bit_size)
- warning(sym->pos, "impossible field-width, %d, for this type", sym->bit_size);
+ if (sym->bit_size > base_type->bit_size) {
+ sparse_error(sym->pos, "impossible field-width, %d, for this type", sym->bit_size);
+ sym->bit_size = -1;
+ }
alignment = base_type->ctype.alignment;
if (!sym->ctype.alignment)
diff --git a/validation/bitfield-sizes.c b/validation/bitfield-sizes.c
index e30a3e4c..c43bb0a4 100644
--- a/validation/bitfield-sizes.c
+++ b/validation/bitfield-sizes.c
@@ -19,7 +19,6 @@ static struct b b;
/*
* check-name: bitfield-sizes
* check-command: sparse -m64 $file
- * check-known-to-fail
*
* check-error-start
bitfield-sizes.c:12:18: error: invalid bitfield width, -1.