From: Wolfgang Bumiller Date: Wed, 29 May 2013 15:08:03 +0000 (+0200) Subject: now a bare 'return;' is not required anymore if return has been assigned anywhere X-Git-Tag: v0.3.0~151^2~31^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ba781c53ef8722cf826607f8cd4c949febeab01d;p=xonotic%2Fgmqcc.git now a bare 'return;' is not required anymore if return has been assigned anywhere --- diff --git a/ast.c b/ast.c index 35b1a7d..81e1c12 100644 --- a/ast.c +++ b/ast.c @@ -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)) { diff --git a/tests/rassign.qc b/tests/rassign.qc index f39b6ea..5c72e6f 100644 --- a/tests/rassign.qc +++ b/tests/rassign.qc @@ -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() {