aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLinus Torvalds <torvalds@penguin.transmeta.com>2003-04-09 19:23:23 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:00:27 -0700
commit53a0adb26d707df1ddd7dc2b24a0b5648cbe5d89 (patch)
tree8341a5ea49fd24238c44f37f7b985780b0b16255
parentc906c75fc353ecdaf288d22ed947ceff83683d50 (diff)
downloadsparse-dev-53a0adb26d707df1ddd7dc2b24a0b5648cbe5d89.tar.gz
Fix type merging at dereference evaluation time.
Use the existing type merging function.
-rw-r--r--evaluate.c6
-rw-r--r--symbol.c2
-rw-r--r--symbol.h1
3 files changed, 6 insertions, 3 deletions
diff --git a/evaluate.c b/evaluate.c
index 7e239a72..19b46623 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -866,13 +866,15 @@ static struct symbol *evaluate_dereference(struct expression *expr)
struct symbol *ctype = op->ctype, *sym;
sym = alloc_symbol(expr->pos, SYM_NODE);
- if (ctype->type == SYM_NODE)
+ sym->ctype = ctype->ctype;
+ if (ctype->type == SYM_NODE) {
ctype = ctype->ctype.base_type;
+ merge_type(sym, ctype);
+ }
if (ctype->type != SYM_PTR && ctype->type != SYM_ARRAY) {
warn(expr->pos, "cannot derefence this type");
return 0;
}
- sym->ctype = ctype->ctype;
ctype = ctype->ctype.base_type;
examine_symbol_type(ctype);
diff --git a/symbol.c b/symbol.c
index 8ebe910c..a1f99c41 100644
--- a/symbol.c
+++ b/symbol.c
@@ -176,7 +176,7 @@ static void examine_bitfield_type(struct symbol *sym)
/*
* "typeof" will have to merge the types together
*/
-static void merge_type(struct symbol *sym, struct symbol *base_type)
+void merge_type(struct symbol *sym, struct symbol *base_type)
{
sym->ctype.as |= base_type->ctype.as;
sym->ctype.modifiers |= base_type->ctype.modifiers;
diff --git a/symbol.h b/symbol.h
index 24f31d52..74d9413a 100644
--- a/symbol.h
+++ b/symbol.h
@@ -189,5 +189,6 @@ extern void examine_simple_symbol_type(struct symbol *);
extern const char *show_typename(struct symbol *sym);
extern void debug_symbol(struct symbol *);
+extern void merge_type(struct symbol *sym, struct symbol *base_type);
#endif /* SEMANTIC_H */