mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-27 06:02:22 +00:00
now a bare 'return;' is not required anymore if return has been assigned anywhere
This commit is contained in:
parent
a76702cb36
commit
ba781c53ef
2 changed files with 7 additions and 4 deletions
9
ast.c
9
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))
|
||||
{
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue