fix: missing-return check: vec_size(entries) is 0 on the entry-block, also check if it's the first block

This commit is contained in:
Wolfgang Bumiller 2013-01-14 10:56:56 +01:00
parent bec05f1bbb
commit d7f4e981a3

4
ast.c
View file

@ -1599,7 +1599,7 @@ bool ast_function_codegen(ast_function *self, ir_builder *ir)
return false;
}
self->curblock = ir_function_create_block(ast_ctx(self), irf, "entry");
irf->first = self->curblock = ir_function_create_block(ast_ctx(self), irf, "entry");
if (!self->curblock) {
compile_error(ast_ctx(self), "failed to allocate entry block for `%s`", self->name);
return false;
@ -1633,7 +1633,7 @@ bool ast_function_codegen(ast_function *self, ir_builder *ir)
{
return ir_block_create_return(self->curblock, ast_ctx(self), NULL);
}
else if (vec_size(self->curblock->entries))
else if (vec_size(self->curblock->entries) || self->curblock == irf->first)
{
/* error("missing return"); */
if (compile_warning(ast_ctx(self), WARN_MISSING_RETURN_VALUES,