Delay calling find_type for enums.

As find_type encodes the type too, calling find_type before the enumerators
have been created causes the type encoding to lose the enumerators.
This commit is contained in:
Bill Currie 2013-01-17 20:55:25 +09:00
parent 7a504f8983
commit 46d2959908
3 changed files with 12 additions and 2 deletions

View file

@ -49,6 +49,7 @@ struct symbol_s *build_struct (int su, struct symbol_s *tag,
struct symtab_s *symtab, struct type_s *type);
struct symbol_s *find_enum (struct symbol_s *tag);
struct symtab_s *start_enum (struct symbol_s *enm);
struct symbol_s *finish_enum (struct symbol_s *sym);
void add_enum (struct symbol_s *enm, struct symbol_s *name,
struct expr_s *val);
int enum_as_bool (struct type_s *enm, struct expr_s **zero,

View file

@ -552,7 +552,10 @@ optional_enum_list
;
enum_list
: '{' enum_init enumerator_list optional_comma '}' { $$ = $3; }
: '{' enum_init enumerator_list optional_comma '}'
{
$$ = finish_enum ($3);
}
;
enum_init

View file

@ -153,10 +153,16 @@ start_enum (symbol_t *sym)
sym = find_enum (0);
}
sym->type->t.symtab = new_symtab (current_symtab, stab_local);
sym->type = find_type (sym->type);
return sym->type->t.symtab;
}
symbol_t *
finish_enum (symbol_t *sym)
{
sym->type = find_type (sym->type);
return sym;
}
void
add_enum (symbol_t *enm, symbol_t *name, expr_t *val)
{