now a bare 'return;' is not required anymore if return has been assigned anywhere

This commit is contained in:
Wolfgang Bumiller 2013-05-29 17:08:03 +02:00
parent a76702cb36
commit ba781c53ef
2 changed files with 7 additions and 4 deletions

9
ast.c
View file

@ -1685,8 +1685,13 @@ bool ast_function_codegen(ast_function *self, ir_builder *ir)
}
else if (vec_size(self->curblock->entries) || self->curblock == irf->first)
{
/* error("missing return"); */
if (compile_warning(ast_ctx(self), WARN_MISSING_RETURN_VALUES,
if (self->return_value) {
cgen = self->return_value->expression.codegen;
if (!(*cgen)((ast_expression*)(self->return_value), self, false, &dummy))
return false;
return ir_block_create_return(self->curblock, ast_ctx(self), dummy);
}
else if (compile_warning(ast_ctx(self), WARN_MISSING_RETURN_VALUES,
"control reaches end of non-void function (`%s`) via %s",
self->name, self->curblock->label))
{

View file

@ -25,8 +25,6 @@ string f_string() {
float factorial(float n) {
if (n == 0) return = 1;
else return = n * factorial(n - 1);
return;
}
void main() {