mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-02-17 09:02:25 +00:00
Enforce void type on accumulatable functions.
This commit is contained in:
parent
2c975bb344
commit
4da820ef61
1 changed files with 11 additions and 1 deletions
12
parser.c
12
parser.c
|
@ -3991,11 +3991,21 @@ static bool parse_function_body(parser_t *parser, ast_value *var)
|
|||
}
|
||||
|
||||
/* accumulation? */
|
||||
if (var->hasvalue) {
|
||||
if (var->hasvalue && var->expression.vtype == TYPE_FUNCTION) {
|
||||
ast_value *accum = NULL;
|
||||
ast_function *previous = NULL;
|
||||
char acname[1024];
|
||||
|
||||
/* only void please */
|
||||
if (var->expression.next->vtype != TYPE_VOID) {
|
||||
parseerror(parser, "accumulated function `%s` declared with return type `%s` (accumulated functions must return void)",
|
||||
var->name,
|
||||
type_name[var->expression.next->vtype]
|
||||
);
|
||||
ast_block_delete(block);
|
||||
goto enderr;
|
||||
}
|
||||
|
||||
/* generate a new name increasing the accumulation count*/
|
||||
util_snprintf(acname, sizeof(acname), "$ACCUMULATE_%s_%d", var->name, var->constval.vfunc->accumulation++);
|
||||
accum = ast_value_new(parser_ctx(parser), acname, ((ast_expression*)var)->vtype);
|
||||
|
|
Loading…
Reference in a new issue