aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@home.transmeta.com>2003-05-26 21:06:33 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:00:45 -0700
commitbb5b108c342b889b404577badc907f7b84842e5d (patch)
tree5009b80a71fc1bb04a9a66b423b3e5d6e906e284
parenta10932174ca47672bc8f62a5b98fbcfb34ee534b (diff)
downloadsparse-bb5b108c342b889b404577badc907f7b84842e5d.tar.gz
sparse-bb5b108c342b889b404577badc907f7b84842e5d.tar.xz
sparse-bb5b108c342b889b404577badc907f7b84842e5d.zip
Fix enums. We can't turn _all_ enums into values, only the actual
value symbols, of course. Make the enum symbols have the SYM_ENUM type, and check that properly at evaluate time (instead of checking the base type, which will be an enum for regular enum variables too, of course).
-rw-r--r--evaluate.c3
-rw-r--r--parse.c2
2 files changed, 3 insertions, 2 deletions
diff --git a/evaluate.c b/evaluate.c
index 458bc83..9874096 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -58,7 +58,7 @@ static struct symbol *evaluate_symbol_expression(struct expression *expr)
expr->ctype = sym;
/* enum's can be turned into plain values */
- if (base_type->type != SYM_ENUM) {
+ if (sym->type != SYM_ENUM) {
struct expression *addr = alloc_expression(expr->pos, EXPR_SYMBOL);
addr->symbol = sym;
addr->symbol_name = expr->symbol_name;
@@ -70,6 +70,7 @@ static struct symbol *evaluate_symbol_expression(struct expression *expr)
}
expr->type = EXPR_VALUE;
expr->value = sym->value;
+ expr->ctype = base_type;
return sym;
}
diff --git a/parse.c b/parse.c
index d717680..2670375 100644
--- a/parse.c
+++ b/parse.c
@@ -117,7 +117,7 @@ static struct token *parse_enum_declaration(struct token *token, struct symbol *
struct token *next = token->next;
struct symbol *sym;
- sym = alloc_symbol(token->pos, SYM_NODE);
+ sym = alloc_symbol(token->pos, SYM_ENUM);
bind_symbol(sym, token->ident, NS_SYMBOL);
sym->ctype.base_type = parent;