Fix some error-recovery segfaults.

This commit is contained in:
Bill Currie 2011-02-14 21:25:55 +09:00
parent f1fccb19dd
commit 5707888fcf
3 changed files with 11 additions and 8 deletions

View file

@ -491,15 +491,17 @@ emit_ivars (symtab_t *ivars, const char *name)
{"ivar_list", 0, emit_ivar_list_item},
{0, 0}
};
ivar_data_t ivar_data = {0, 0};
ivar_data_t ivar_data = {0, 0, 0};
symbol_t *s;
def_t *def;
ivar_data.encoding = dstring_newstr ();
ivar_data.ivars = ivars->symbols;
for (s = ivars->symbols; s; s = s->next)
if (s->sy_type == sy_var)
ivar_data.count++;
if (ivars) {
ivar_data.ivars = ivars->symbols;
for (s = ivars->symbols; s; s = s->next)
if (s->sy_type == sy_var)
ivar_data.count++;
}
ivar_list_struct[1].type = array_type (&type_ivar, ivar_data.count);
def = emit_structure (va ("_OBJ_INSTANCE_VARIABLES_%s", name), 's',

View file

@ -224,8 +224,6 @@ get_function (const char *name, type_t *type, int overload, int create)
func = Hash_Find (overloaded_functions, full_name);
if (func) {
if (func->type != type) {
print_type (func->type); printf (" %p\n", func->type);
print_type (type); printf (" %p\n", type);
error (0, "can't overload on return types");
return func;
}
@ -534,7 +532,8 @@ begin_function (symbol_t *sym, const char *nicename, symtab_t *parent)
}
if (sym->s.func && sym->s.func->def && sym->s.func->def->initialized) {
error (0, "%s redefined", sym->name);
sym = function_symbol (new_symbol (sym->name), 1, 1);
sym = new_symbol_type (sym->name, sym->type);
sym = function_symbol (sym, 1, 1);
}
make_function (sym, nicename, current_storage);
if (!sym->s.func->def->external) {

View file

@ -1411,6 +1411,8 @@ ivar_decl_list
ivars = class_new_ivars ($<class>0);
for (tab = ivars; tab->parent; tab = tab->parent)
;
if (tab == current_symtab)
internal_error (0, "ivars already linked to parent scope");
$<symtab>$ = tab;
tab->parent = current_symtab;
current_symtab = ivars;