print a proper error message when a function lacks a body

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-08-16 15:31:46 +02:00
parent ec439d7880
commit 98567e20f3

6
ast.c
View file

@ -846,6 +846,11 @@ bool ast_function_codegen(ast_function *self, ir_builder *ir)
return true;
}
if (!self->blocks_count) {
asterror(ast_ctx(self), "function `%s` has no body", self->name);
return false;
}
self->curblock = ir_function_create_block(irf, "entry");
if (!self->curblock)
return false;
@ -867,6 +872,7 @@ bool ast_function_codegen(ast_function *self, ir_builder *ir)
else
{
/* error("missing return"); */
asterror(ast_ctx(self), "function `%s` missing return value", self->name);
return false;
}
}