From 46122235e62fa92cca4115b4331f9cb3703a8025 Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Thu, 3 May 2012 14:15:02 +0200 Subject: [PATCH] ast_function_codegen: Add a return instruction if it is missing, or error if we're not in a void-function --- ast.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ast.c b/ast.c index 47638cb..77d10f0 100644 --- 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; } -- 2.39.2