diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-10-28 11:00:11 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 21:03:47 -0700 |
commit | a89fb02dce4cc0631da5ba173f5680993df58f29 (patch) | |
tree | 70076e6d23fcd44521bf464c488f372d7211cb2d /symbol.c | |
parent | 1b872b55117762f1e3eb31320cb2539a58ecdfec (diff) | |
download | sparse-a89fb02dce4cc0631da5ba173f5680993df58f29.tar.gz |
Do base_type examination in common code in examine_symbol_type().
Also, check it for enums. This should also make sure that we handle
"typeof" properly in all cases.
Diffstat (limited to 'symbol.c')
-rw-r--r-- | symbol.c | 30 |
1 files changed, 14 insertions, 16 deletions
@@ -249,14 +249,12 @@ static int count_array_initializer(struct expression *expr) return nr; } -static void examine_node_type(struct symbol *sym) +static void examine_node_type(struct symbol *sym, struct symbol *base_type) { - struct symbol *base_type; int bit_size; unsigned long alignment, modifiers; /* SYM_NODE - figure out what the type of the node was.. */ - base_type = sym->ctype.base_type; modifiers = sym->ctype.modifiers; bit_size = 0; @@ -264,11 +262,6 @@ static void examine_node_type(struct symbol *sym) if (!base_type) return; - base_type = examine_symbol_type(base_type); - sym->ctype.base_type = base_type; - if (base_type && base_type->type == SYM_NODE) - merge_type(sym, base_type); - bit_size = base_type->bit_size; alignment = base_type->ctype.alignment; if (base_type->fieldwidth) @@ -304,10 +297,21 @@ struct symbol *examine_symbol_type(struct symbol * sym) if (sym->bit_size) return sym; + /* Check the basetype */ + 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 = base_type->ctype.base_type; + } + } + switch (sym->type) { case SYM_FN: case SYM_NODE: - examine_node_type(sym); + examine_node_type(sym, base_type); return sym; case SYM_ARRAY: examine_array_type(sym); @@ -323,15 +327,9 @@ struct symbol *examine_symbol_type(struct symbol * sym) sym->bit_size = bits_in_pointer; if (!sym->ctype.alignment) sym->ctype.alignment = pointer_alignment; - base_type = sym->ctype.base_type; - base_type = examine_symbol_type(base_type); - if (base_type && base_type->type == SYM_NODE) - merge_type(sym, base_type); return sym; case SYM_ENUM: - base_type = sym->ctype.base_type; - base_type = examine_symbol_type(base_type); - if (base_type == &bad_enum_ctype) { + if (!base_type || base_type == &bad_enum_ctype) { warning(sym->pos, "invalid enum type"); sym->bit_size = -1; return sym; |