From: Wolfgang (Blub) Bumiller Date: Thu, 3 May 2012 12:15:02 +0000 (+0200) Subject: ast_function_codegen: Add a return instruction if it is missing, or error if we're... X-Git-Tag: 0.1-rc1~500 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=46122235e62fa92cca4115b4331f9cb3703a8025;p=xonotic%2Fgmqcc.git ast_function_codegen: Add a return instruction if it is missing, or error if we're not in a void-function --- 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; }