Ensure structs get added to the symbol table.

This commit is contained in:
Bill Currie 2011-02-02 22:53:53 +09:00
parent a4eaa2a89b
commit 4420a7125e

View file

@ -464,14 +464,23 @@ struct_specifier
} }
struct_defs '}' struct_defs '}'
{ {
symbol_t *sym;
symtab_t *symtab = current_symtab; symtab_t *symtab = current_symtab;
current_symtab = symtab->parent; current_symtab = symtab->parent;
$$ = make_spec (build_struct ($1, $2, symtab, 0)->type, 0, 0); sym = build_struct ($1, $2, symtab, 0);
$$ = make_spec (sym->type, 0, 0);
if (!sym->table)
symtab_addsymbol (current_symtab, sym);
} }
| STRUCT tag | STRUCT tag
{ {
$$ = make_spec (find_struct ($1, $2, 0)->type, 0, 0); symbol_t *sym;
sym = find_struct ($1, $2, 0);
$$ = make_spec (sym->type, 0, 0);
if (!sym->table)
symtab_addsymbol (current_symtab, sym);
} }
; ;