diff options
author | 2004-11-03 16:02:26 -0700 | |
---|---|---|
committer | 2005-04-07 21:03:58 -0700 | |
commit | db5cb961ca472b8b136282f37890842f3df63e46 (patch) | |
tree | d7e210d9d40d4209d6226ac638f720434de928fa /symbol.c | |
parent | Make the cast truncation warning a bit more readable. (diff) | |
download | sparse-db5cb961ca472b8b136282f37890842f3df63e46.tar.gz sparse-db5cb961ca472b8b136282f37890842f3df63e46.tar.bz2 sparse-db5cb961ca472b8b136282f37890842f3df63e46.zip |
enums, bitfields and nodes pick up their signedness
from the base type.
This fixes some code that checks the sign of the node
instead of on the base type.
Diffstat (limited to 'symbol.c')
-rw-r--r-- | symbol.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -219,7 +219,7 @@ 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; + unsigned long bit_size, alignment, modifiers; if (!base_type) return sym; @@ -230,6 +230,12 @@ static struct symbol *examine_bitfield_type(struct symbol *sym) alignment = base_type->ctype.alignment; if (!sym->ctype.alignment) sym->ctype.alignment = alignment; + modifiers = base_type->ctype.modifiers; + + /* Bitfields are unsigned, unless the base type was explicitly signed */ + if (!(modifiers & MOD_EXPLICITLY_SIGNED)) + modifiers = (modifiers & ~MOD_SIGNED) | MOD_UNSIGNED; + sym->ctype.modifiers |= modifiers & MOD_SIGNEDNESS; return sym; } @@ -293,6 +299,9 @@ static struct symbol * examine_node_type(struct symbol *sym) bit_size = base_type->bit_size; alignment = base_type->ctype.alignment; + /* Pick up signedness information into the node */ + sym->ctype.modifiers |= (MOD_SIGNEDNESS & base_type->ctype.modifiers); + if (!sym->ctype.alignment) sym->ctype.alignment = alignment; @@ -318,6 +327,7 @@ static struct symbol *examine_enum_type(struct symbol *sym) sym->bit_size = -1; return sym; } + sym->ctype.modifiers |= (base_type->ctype.modifiers & MOD_SIGNEDNESS); sym->bit_size = bits_in_enum; if (base_type->bit_size > sym->bit_size) sym->bit_size = base_type->bit_size; |