Gracefully handle returning NIL though a bad type.

This commit is contained in:
Bill Currie 2010-11-18 09:02:12 +09:00
parent c460e3c979
commit e28ee0378f
2 changed files with 19 additions and 0 deletions

View file

@ -2138,6 +2138,8 @@ return_expr (function_t *f, expr_t *e)
if (e->type == ex_nil) {
t = f->def->type->aux_type;
e->type = expr_types[t->type];
if (e->type == ex_nil)
return error (e, "invalid return type for NIL");
} else {
if (!options.traditional)
return error (e, "void value not ignored as it ought to be");

View file

@ -1 +1,18 @@
Class x = NIL;
struct Size {
integer x;
integer y;
};
typedef struct Size Size;
@interface foo
-(Size) bar;
@end
@implementation foo
-(Size) bar
{
local Size s;
return NIL;
}
@end