]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
now a bare 'return;' is not required anymore if return has been assigned anywhere
authorWolfgang Bumiller <wry.git@bumiller.com>
Wed, 29 May 2013 15:08:03 +0000 (17:08 +0200)
committerWolfgang Bumiller <wry.git@bumiller.com>
Wed, 29 May 2013 15:08:03 +0000 (17:08 +0200)
ast.c
tests/rassign.qc

diff --git a/ast.c b/ast.c
index 35b1a7dfa26b850f0c7103ec61b23da9792a13fb..81e1c121231e16bbb9bdde2c92cf72ec642fda1b 100644 (file)
--- 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))
             {
index f39b6ea86716ce6fb3e5d1e35e91c099ac9db972..5c72e6f52fa3df9175ccf6fa52b719e3b249a367 100644 (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() {