aboutsummaryrefslogtreecommitdiffstats
path: root/symbol.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2004-10-28 11:00:11 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:03:47 -0700
commita89fb02dce4cc0631da5ba173f5680993df58f29 (patch)
tree70076e6d23fcd44521bf464c488f372d7211cb2d /symbol.c
parent1b872b55117762f1e3eb31320cb2539a58ecdfec (diff)
downloadsparse-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.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/symbol.c b/symbol.c
index ab7c5b44..ad373ecb 100644
--- a/symbol.c
+++ b/symbol.c
@@ -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;