mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-03-21 18:30:52 +00:00
ast_function_codegen: Add a return instruction if it is missing, or error if we're not in a void-function
This commit is contained in:
parent
bd84ebcf74
commit
46122235e6
1 changed files with 13 additions and 0 deletions
13
ast.c
13
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue