fix a segfault due to type mangling for ... functions

This commit is contained in:
Bill Currie 2001-08-20 18:23:47 +00:00
parent 7df09a3487
commit 2af74aedca

View file

@ -973,6 +973,7 @@ function_expr (expr_t *e1, expr_t *e2)
expr_t *args = 0, **a = &args; expr_t *args = 0, **a = &args;
type_t *arg_types[MAX_PARMS]; type_t *arg_types[MAX_PARMS];
expr_t *call; expr_t *call;
expr_t *err = 0;
t1 = get_type (e1); t1 = get_type (e1);
@ -1008,12 +1009,12 @@ function_expr (expr_t *e1, expr_t *e2)
return error (e1, "more than %d parameters", MAX_PARMS); return error (e1, "more than %d parameters", MAX_PARMS);
} }
if (ftype->num_parms != -1) { if (ftype->num_parms != -1) {
expr_t *err = 0;
if (parm_count > ftype->num_parms) { if (parm_count > ftype->num_parms) {
return error (e1, "too many arguments"); return error (e1, "too many arguments");
} else if (parm_count < ftype->num_parms) { } else if (parm_count < ftype->num_parms) {
return error (e1, "too few arguments"); return error (e1, "too few arguments");
} }
}
for (i = parm_count, e = e2; i > 0; i--, e = e->next) { for (i = parm_count, e = e2; i > 0; i--, e = e->next) {
type_t *t; type_t *t;
if (e->type == ex_expr) { if (e->type == ex_expr) {
@ -1028,18 +1029,18 @@ function_expr (expr_t *e1, expr_t *e2)
} }
t = types[get_type (e)]; t = types[get_type (e)];
} }
if (ftype->num_parms != -1) {
if (t != ftype->parm_types[i - 1]) if (t != ftype->parm_types[i - 1])
err = error (e, "type mismatch for parameter %d of %s", err = error (e, "type mismatch for parameter %d of %s",
i, e1->e.def->name); i, e1->e.def->name);
} else {
//if (e->type == ex_integer)
// warning (e, "passing integer consant into ... function");
}
arg_types[parm_count - i] = t; arg_types[parm_count - i] = t;
} }
if (err) if (err)
return err; return err;
} else {
//for (e = e2; e; e = e->next)
// if (e->type == ex_integer)
// warning (e, "passing integer consant into ... function");
}
call = new_block_expr (); call = new_block_expr ();
for (e = e2, i = 0; e; e = e->next, i++) { for (e = e2, i = 0; e; e = e->next, i++) {