aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2007-07-12 21:20:06 -0400
committerJosh Triplett <josh@freedesktop.org>2007-07-14 12:16:53 -0700
commit984b7b66457cd9fe534c771317f74b66141e76af (patch)
treee11f6d3976925cc2a7a78dd7da3ca0f09aa3623f /symbol.c
parent[PATCH] rewrite type_difference() (diff)
downloadsparse-984b7b66457cd9fe534c771317f74b66141e76af.tar.gz
sparse-984b7b66457cd9fe534c771317f74b66141e76af.tar.bz2
sparse-984b7b66457cd9fe534c771317f74b66141e76af.zip
[PATCH] deal correctly with qualifiers on arrays
* new helper: examine_pointer_target(). Examine target, find address_space et.al. If the target is SYM_NODE - merge it, etc. * new helper: target_qualifiers(). Pointers to any array are considered as pointers to unqualified type as far as implicit conversions are concerned; handle that right. * SYM_TYPEOF can be handled sanely now: don't copy the node, just convert SYM_TYPEOF to SYM_NODE and examine that. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'symbol.c')
-rw-r--r--symbol.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/symbol.c b/symbol.c
index 9c105c2..7539817 100644
--- a/symbol.c
+++ b/symbol.c
@@ -194,13 +194,16 @@ static struct symbol *examine_base_type(struct symbol *sym)
struct symbol *base_type;
/* Check the base type */
- base_type = sym->ctype.base_type;
- if (base_type) {
- base_type = examine_symbol_type(base_type);
-
- /* "typeof" can cause this */
- if (base_type && base_type->type == SYM_NODE)
- merge_type(sym, base_type);
+ base_type = examine_symbol_type(sym->ctype.base_type);
+ if (!base_type || base_type->type == SYM_PTR)
+ return base_type;
+ sym->ctype.as |= base_type->ctype.as;
+ sym->ctype.modifiers |= base_type->ctype.modifiers & MOD_PTRINHERIT;
+ concat_ptr_list((struct ptr_list *)base_type->ctype.contexts,
+ (struct ptr_list **)&sym->ctype.contexts);
+ if (base_type->type == SYM_NODE) {
+ base_type = base_type->ctype.base_type;
+ sym->ctype.base_type = base_type;
}
return base_type;
}
@@ -411,17 +414,10 @@ struct symbol *examine_symbol_type(struct symbol * sym)
warning(base->pos, "typeof applied to bitfield type");
if (base->type == SYM_NODE)
base = base->ctype.base_type;
- switch (base->type) {
- case SYM_RESTRICT:
- case SYM_UNION:
- case SYM_STRUCT:
- sym->type = SYM_NODE;
- sym->ctype.modifiers = 0;
- sym->ctype.base_type = base;
- return examine_node_type(sym);
- }
- *sym = *base;
- break;
+ sym->type = SYM_NODE;
+ sym->ctype.modifiers = 0;
+ sym->ctype.base_type = base;
+ return examine_node_type(sym);
}
break;
}
@@ -473,6 +469,11 @@ const char* get_type_name(enum type type)
return NULL;
}
+struct symbol *examine_pointer_target(struct symbol *sym)
+{
+ return examine_base_type(sym);
+}
+
static struct symbol_list *restr, *fouled;
void create_fouled(struct symbol *type)