mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-30 07:31:28 +00:00
add error for function parameters of invalid types
This commit is contained in:
parent
201bfb9803
commit
478a9249a0
3 changed files with 20 additions and 0 deletions
17
ast.c
17
ast.c
|
@ -589,6 +589,23 @@ void ast_call_delete(ast_call *self)
|
||||||
mem_d(self);
|
mem_d(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ast_call_check_types(ast_call *self)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
bool retval = true;
|
||||||
|
const ast_expression *func = self->func;
|
||||||
|
|
||||||
|
for (i = 0; i < self->params_count; ++i) {
|
||||||
|
if (!ast_compare_type(self->params[i], (ast_expression*)(func->expression.params[i]))) {
|
||||||
|
asterror(ast_ctx(self), "invalid type for parameter %u in function call",
|
||||||
|
(unsigned int)(i+1));
|
||||||
|
/* we don't immediately return */
|
||||||
|
retval = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
ast_store* ast_store_new(lex_ctx ctx, int op,
|
ast_store* ast_store_new(lex_ctx ctx, int op,
|
||||||
ast_expression *dest, ast_expression *source)
|
ast_expression *dest, ast_expression *source)
|
||||||
{
|
{
|
||||||
|
|
1
ast.h
1
ast.h
|
@ -423,6 +423,7 @@ ast_call* ast_call_new(lex_ctx ctx,
|
||||||
ast_expression *funcexpr);
|
ast_expression *funcexpr);
|
||||||
void ast_call_delete(ast_call*);
|
void ast_call_delete(ast_call*);
|
||||||
bool ast_call_codegen(ast_call*, ast_function*, bool lvalue, ir_value**);
|
bool ast_call_codegen(ast_call*, ast_function*, bool lvalue, ir_value**);
|
||||||
|
bool ast_call_check_types(ast_call*);
|
||||||
|
|
||||||
MEM_VECTOR_PROTO(ast_call, ast_expression*, params);
|
MEM_VECTOR_PROTO(ast_call, ast_expression*, params);
|
||||||
|
|
||||||
|
|
2
parser.c
2
parser.c
|
@ -967,6 +967,8 @@ static bool parser_close_call(parser_t *parser, shunt *sy)
|
||||||
MEM_VECTOR_MOVE(params, exprs, call, params);
|
MEM_VECTOR_MOVE(params, exprs, call, params);
|
||||||
ast_delete(params);
|
ast_delete(params);
|
||||||
}
|
}
|
||||||
|
if (!ast_call_check_types(call))
|
||||||
|
parser->errors++;
|
||||||
} else {
|
} else {
|
||||||
parseerror(parser, "invalid function call");
|
parseerror(parser, "invalid function call");
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue