aboutsummaryrefslogtreecommitdiffstats
path: root/symbol.c
diff options
context:
space:
mode:
authorwelinder@troll.com <welinder@troll.com>2004-08-12 14:22:54 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:02:41 -0700
commit1f6e86b5454c556f277367d05a5856ac92485b6b (patch)
tree14c2c722987a966288e4889cc631dfa14a63ca30 /symbol.c
parent926a23d2e74e86343a5636157b4dff0c5b75b879 (diff)
downloadsparse-1f6e86b5454c556f277367d05a5856ac92485b6b.tar.gz
symbol.c:
Check for signed one-bit bitfields.
Diffstat (limited to 'symbol.c')
-rw-r--r--symbol.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/symbol.c b/symbol.c
index d406c8aa..95f1e569 100644
--- a/symbol.c
+++ b/symbol.c
@@ -161,15 +161,24 @@ static void examine_bitfield_type(struct symbol *sym)
{
struct symbol *base_type = sym->ctype.base_type;
unsigned long bit_size, alignment;
+ int is_signed;
if (!base_type)
return;
examine_symbol_type(base_type);
bit_size = base_type->bit_size;
if (sym->fieldwidth > bit_size) {
- warn(sym->pos, "impossible field-width for this type");
+ warn(sym->pos, "impossible field-width, %d, for this type",
+ sym->fieldwidth);
sym->fieldwidth = bit_size;
}
+
+ is_signed = !(base_type->ctype.modifiers & MOD_UNSIGNED);
+ if (sym->fieldwidth == 1 && is_signed) {
+ // Valid values are either {-1;0} or {0}, depending on integer
+ // representation. The latter makes for very efficient code...
+ warn(sym->pos, "dubious one-bit signed bitfield");
+ }
alignment = base_type->ctype.alignment;
if (!sym->ctype.alignment)
sym->ctype.alignment = alignment;