diff options
author | 2007-07-12 21:20:06 -0400 | |
---|---|---|
committer | 2007-07-14 12:16:53 -0700 | |
commit | 984b7b66457cd9fe534c771317f74b66141e76af (patch) | |
tree | e11f6d3976925cc2a7a78dd7da3ca0f09aa3623f /symbol.c | |
parent | [PATCH] rewrite type_difference() (diff) | |
download | sparse-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.c | 37 |
1 files changed, 19 insertions, 18 deletions
@@ -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) |