]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
ast_function_codegen: Add a return instruction if it is missing, or error if we're...
authorWolfgang (Blub) Bumiller <blub@speed.at>
Thu, 3 May 2012 12:15:02 +0000 (14:15 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Thu, 3 May 2012 12:15:02 +0000 (14:15 +0200)
ast.c

diff --git a/ast.c b/ast.c
index 47638cb1dd561471d066457d85aec4d55faac952..77d10f0feb781214aa6c39fe2d084189bca9cc52 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -545,6 +545,19 @@ bool ast_function_codegen(ast_function *self, ir_builder *ir)
         if (!(*gen)((ast_expression*)self->blocks[i], self, false, &dummy))
             return false;
     }
+
+    /* TODO: check return types */
+    if (!self->curblock->is_return)
+    {
+        if (!self->vtype->expression.next ||
+            self->vtype->expression.next->expression.vtype == TYPE_VOID)
+            return ir_block_create_return(self->curblock, NULL);
+        else
+        {
+            /* error("missing return"); */
+            return false;
+        }
+    }
     return true;
 }