diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-12-15 09:46:12 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-12-15 20:41:46 +0100 |
commit | f8255903ad142da2bd0a19f5313d25f4f96b8452 (patch) | |
tree | 6ef00507504cce73ba231bf2006d544bd9ab34c8 | |
parent | cd18af40c57e6617c0e45bbdd3ec594ba99ccb74 (diff) | |
download | sparse-f8255903ad142da2bd0a19f5313d25f4f96b8452.tar.gz |
typeof: extract examine_typeof() from examine_symbol_type()
No functional changes here, just moving the code for the
conversion of SYM_TYPEOFs in its own function, in preparation
for some further changes.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | symbol.c | 41 |
1 files changed, 21 insertions, 20 deletions
@@ -453,6 +453,25 @@ static struct symbol *examine_pointer_type(struct symbol *sym) return sym; } +static struct symbol *examine_typeof(struct symbol *sym) +{ + struct symbol *base = evaluate_expression(sym->initializer); + unsigned long mod = 0; + + if (!base) + base = &bad_ctype; + if (is_bitfield_type(base)) + warning(base->pos, "typeof applied to bitfield type"); + if (base->type == SYM_NODE) { + mod |= base->ctype.modifiers & MOD_TYPEOF; + base = base->ctype.base_type; + } + sym->type = SYM_NODE; + sym->ctype.modifiers = mod; + sym->ctype.base_type = base; + return examine_node_type(sym); +} + /* * Fill in type size and alignment information for * regular SYM_TYPE things. @@ -486,26 +505,8 @@ struct symbol *examine_symbol_type(struct symbol * sym) case SYM_BASETYPE: /* Size and alignment had better already be set up */ return sym; - case SYM_TYPEOF: { - struct symbol *base = evaluate_expression(sym->initializer); - if (base) { - unsigned long mod = 0; - - if (is_bitfield_type(base)) - warning(base->pos, "typeof applied to bitfield type"); - if (base->type == SYM_NODE) { - mod |= base->ctype.modifiers & MOD_TYPEOF; - base = base->ctype.base_type; - } - sym->type = SYM_NODE; - sym->ctype.modifiers = mod; - sym->ctype.base_type = base; - return examine_node_type(sym); - } - sym->type = SYM_NODE; - sym->ctype.base_type = &bad_ctype; - return sym; - } + case SYM_TYPEOF: + return examine_typeof(sym); case SYM_PREPROCESSOR: sparse_error(sym->pos, "ctype on preprocessor command? (%s)", show_ident(sym->ident)); return NULL; |