avoid possible segfault
expr.c:
	correct the return value type checking to handle super classes
This commit is contained in:
Bill Currie 2002-05-21 23:29:21 +00:00
parent 3a99ab8cea
commit 4315707008
2 changed files with 6 additions and 4 deletions

View file

@ -304,9 +304,11 @@ class_message_response (class_t *class, expr_t *sel)
selector = &G_STRUCT (pr_sel_t, sel->e.pointer.val);
sel_name = strings + selector->sel_id;
while (c) {
for (m = c->methods->head; m; m = m->next) {
if (strcmp (sel_name, m->name) == 0)
return m;
if (c->methods) {
for (m = c->methods->head; m; m = m->next) {
if (strcmp (sel_name, m->name) == 0)
return m;
}
}
c = c->super_class;
}

View file

@ -1658,7 +1658,7 @@ return_expr (function_t *f, expr_t *e)
t = f->def->type->aux_type;
e->type = expr_types[t->type];
}
if (f->def->type->aux_type != t)
if (!type_assignable (f->def->type->aux_type, t))
return error (e, "type mismatch for return value of %s",
f->def->name);
}