diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-04-20 23:56:04 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-10-05 03:29:19 +0200 |
| commit | 604a148a73af94bd271bbfb0d36dbe77e42bbc4f (patch) | |
| tree | cdef9af050723e02ad23cb4ffea5008f24e481cf /parse.c | |
| parent | 5afb6e9ffe1687cee5648b11d59d05edeb063033 (diff) | |
| download | sparse-dev-604a148a73af94bd271bbfb0d36dbe77e42bbc4f.tar.gz | |
enum: fix cast_enum_list()
Sparse want that an enum's enumerators have all the same type.
This is done by first determining the common type and then
calling cast_enum_list() which use cast_value() on each member
to cast them to the common type.
However, cast_value() doesn't create a new expression and doesn't
change the ctype of the target: the target expression is supposed
to have already the right type and it's just the value that is
transfered from the source expression and size adjusted.
It's seems that in cast_enum_list() this has been overlooked
with the result that the value is correctly adjusted but keep
it's original type.
Fix this by updating, for each member, the desired type.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'parse.c')
| -rw-r--r-- | parse.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -855,6 +855,7 @@ static void cast_enum_list(struct symbol_list *list, struct symbol *base_type) if (expr->type != EXPR_VALUE) continue; ctype = expr->ctype; + expr->ctype = base_type; if (ctype->bit_size == base_type->bit_size) continue; cast_value(expr, base_type, expr, ctype); |
