diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-10-01 23:24:37 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-11-30 14:05:03 +0100 |
commit | 4ce42ee56d9207ef831f76104fa248fa0fddb326 (patch) | |
tree | fcc68584573fbc0b8ffd6d32131db741caec8317 | |
parent | 600bc3b599fe3488e31a044f45939f9b52d7f7d3 (diff) | |
download | sparse-4ce42ee56d9207ef831f76104fa248fa0fddb326.tar.gz |
bitfield: don't warn twice on invalid width
At parsing time, bitfields with invalid width have their size
set to -1 but at examination time this size is interpreted as
an unsigned value, causing a second warning.
Fix this by avoiding to cast the size to an unsigned variable.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | symbol.c | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -254,12 +254,11 @@ static struct symbol * examine_array_type(struct symbol *sym) static struct symbol *examine_bitfield_type(struct symbol *sym) { struct symbol *base_type = examine_base_type(sym); - unsigned long bit_size, alignment, modifiers; + unsigned long alignment, modifiers; if (!base_type) return sym; - bit_size = base_type->bit_size; - if (sym->bit_size > bit_size) + if (sym->bit_size > base_type->bit_size) warning(sym->pos, "impossible field-width, %d, for this type", sym->bit_size); alignment = base_type->ctype.alignment; |