diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-12-09 21:25:20 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-12-12 18:48:52 +0100 |
commit | 4bf8f31e91c88f7d2bc4e6de0c10b2b89d3093e2 (patch) | |
tree | 55708c7806bb2f48c440b7f521e1aa53ee4dbfc2 | |
parent | 54c243b16fdf43e4cc4bef6aad3e50bc0c32547c (diff) | |
download | sparse-4bf8f31e91c88f7d2bc4e6de0c10b2b89d3093e2.tar.gz |
as-named: warn on bad address space
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | evaluate.c | 14 | ||||
-rw-r--r-- | show-parse.c | 6 | ||||
-rw-r--r-- | symbol.c | 4 | ||||
-rw-r--r-- | symbol.h | 7 |
4 files changed, 17 insertions, 14 deletions
@@ -217,7 +217,7 @@ static struct symbol *base_type(struct symbol *node, unsigned long *modp, struct while (node) { mod |= node->ctype.modifiers; - combine_address_space(&as, node->ctype.as); + combine_address_space(node->pos, &as, node->ctype.as); if (node->type == SYM_NODE) { node = node->ctype.base_type; continue; @@ -681,7 +681,7 @@ const char *type_difference(struct ctype *c1, struct ctype *c2, if (move1) { if (t1 && t1->type != SYM_PTR) { mod1 |= t1->ctype.modifiers; - combine_address_space(&as1, t1->ctype.as); + combine_address_space(t1->pos, &as1, t1->ctype.as); } move1 = 0; } @@ -689,7 +689,7 @@ const char *type_difference(struct ctype *c1, struct ctype *c2, if (move2) { if (t2 && t2->type != SYM_PTR) { mod2 |= t2->ctype.modifiers; - combine_address_space(&as2, t2->ctype.as); + combine_address_space(t2->pos, &as2, t2->ctype.as); } move2 = 0; } @@ -1612,7 +1612,7 @@ static void examine_fn_arguments(struct symbol *fn) ptr->ctype = arg->ctype; else ptr->ctype.base_type = arg; - combine_address_space(&ptr->ctype.as, s->ctype.as); + combine_address_space(s->pos, &ptr->ctype.as, s->ctype.as); ptr->ctype.modifiers |= s->ctype.modifiers & MOD_PTRINHERIT; s->ctype.base_type = ptr; @@ -1662,12 +1662,12 @@ static struct symbol *create_pointer(struct expression *expr, struct symbol *sym sym->ctype.modifiers &= ~MOD_REGISTER; } if (sym->type == SYM_NODE) { - combine_address_space(&ptr->ctype.as, sym->ctype.as); + combine_address_space(sym->pos, &ptr->ctype.as, sym->ctype.as); ptr->ctype.modifiers |= sym->ctype.modifiers & MOD_PTRINHERIT; sym = sym->ctype.base_type; } if (degenerate && sym->type == SYM_ARRAY) { - combine_address_space(&ptr->ctype.as, sym->ctype.as); + combine_address_space(sym->pos, &ptr->ctype.as, sym->ctype.as); ptr->ctype.modifiers |= sym->ctype.modifiers & MOD_PTRINHERIT; sym = sym->ctype.base_type; } @@ -2070,7 +2070,7 @@ static struct symbol *evaluate_member_dereference(struct expression *expr) mod = ctype->ctype.modifiers; if (ctype->type == SYM_NODE) { ctype = ctype->ctype.base_type; - combine_address_space(&address_space, ctype->ctype.as); + combine_address_space(deref->pos, &address_space, ctype->ctype.as); mod |= ctype->ctype.modifiers; } if (!ctype || (ctype->type != SYM_STRUCT && ctype->type != SYM_UNION)) { diff --git a/show-parse.c b/show-parse.c index 0a980a5a..b892c189 100644 --- a/show-parse.c +++ b/show-parse.c @@ -355,12 +355,12 @@ deeper: case SYM_NODE: append(name, "%s", show_ident(sym->ident)); mod |= sym->ctype.modifiers; - combine_address_space(&as, sym->ctype.as); + combine_address_space(sym->pos, &as, sym->ctype.as); break; case SYM_BITFIELD: mod |= sym->ctype.modifiers; - combine_address_space(&as, sym->ctype.as); + combine_address_space(sym->pos, &as, sym->ctype.as); append(name, ":%d", sym->bit_size); break; @@ -370,7 +370,7 @@ deeper: case SYM_ARRAY: mod |= sym->ctype.modifiers; - combine_address_space(&as, sym->ctype.as); + combine_address_space(sym->pos, &as, sym->ctype.as); if (was_ptr) { prepend(name, "( "); append(name, " )"); @@ -214,7 +214,7 @@ static struct symbol *examine_base_type(struct symbol *sym) base_type = examine_symbol_type(sym->ctype.base_type); if (!base_type || base_type->type == SYM_PTR) return base_type; - combine_address_space(&sym->ctype.as, base_type->ctype.as); + combine_address_space(sym->pos, &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); @@ -278,7 +278,7 @@ static struct symbol *examine_bitfield_type(struct symbol *sym) */ void merge_type(struct symbol *sym, struct symbol *base_type) { - combine_address_space(&sym->ctype.as, base_type->ctype.as); + combine_address_space(sym->pos, &sym->ctype.as, base_type->ctype.as); sym->ctype.modifiers |= (base_type->ctype.modifiers & ~MOD_STORAGE); concat_ptr_list((struct ptr_list *)base_type->ctype.contexts, (struct ptr_list **)&sym->ctype.contexts); @@ -508,7 +508,8 @@ static inline bool valid_as(struct ident *as) return as && as != &bad_address_space; } -static inline void combine_address_space(struct ident **tas, struct ident *sas) +static inline void combine_address_space(struct position pos, + struct ident **tas, struct ident *sas) { struct ident *as; if (!sas) @@ -516,8 +517,10 @@ static inline void combine_address_space(struct ident **tas, struct ident *sas) as = *tas; if (!as) *tas = sas; - else if (as != sas) + else if (as != sas) { *tas = &bad_address_space; + sparse_error(pos, "multiple address spaces given"); + } } #endif /* SYMBOL_H */ |