mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-23 12:22:26 +00:00
type restricted varargs
This commit is contained in:
parent
ca947d782c
commit
6a248e2498
1 changed files with 16 additions and 2 deletions
18
ast.c
18
ast.c
|
@ -914,6 +914,8 @@ void ast_call_delete(ast_call *self)
|
|||
|
||||
bool ast_call_check_types(ast_call *self)
|
||||
{
|
||||
char texp[1024];
|
||||
char tgot[1024];
|
||||
size_t i;
|
||||
bool retval = true;
|
||||
const ast_expression *func = self->func;
|
||||
|
@ -924,8 +926,6 @@ bool ast_call_check_types(ast_call *self)
|
|||
for (i = 0; i < count; ++i) {
|
||||
if (!ast_compare_type(self->params[i], (ast_expression*)(func->expression.params[i])))
|
||||
{
|
||||
char texp[1024];
|
||||
char tgot[1024];
|
||||
ast_type_to_string(self->params[i], tgot, sizeof(tgot));
|
||||
ast_type_to_string((ast_expression*)func->expression.params[i], texp, sizeof(texp));
|
||||
compile_error(ast_ctx(self), "invalid type for parameter %u in function call: expected %s, got %s",
|
||||
|
@ -934,6 +934,20 @@ bool ast_call_check_types(ast_call *self)
|
|||
retval = false;
|
||||
}
|
||||
}
|
||||
count = vec_size(self->params);
|
||||
if (count > vec_size(func->expression.params) && func->expression.varparam) {
|
||||
for (; i < count; ++i) {
|
||||
if (!ast_compare_type(self->params[i], func->expression.varparam))
|
||||
{
|
||||
ast_type_to_string(self->params[i], tgot, sizeof(tgot));
|
||||
ast_type_to_string(func->expression.varparam, texp, sizeof(texp));
|
||||
compile_error(ast_ctx(self), "invalid type for parameter %u in function call: expected %s, got %s",
|
||||
(unsigned int)(i+1), texp, tgot);
|
||||
/* we don't immediately return */
|
||||
retval = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue