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,38 +1009,38 @@ 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) { }
type_t *t; for (i = parm_count, e = e2; i > 0; i--, e = e->next) {
if (e->type == ex_expr) { type_t *t;
t = e->e.expr.type; if (e->type == ex_expr) {
} else if (e->type == ex_def) { t = e->e.expr.type;
t = e->e.def->type; } else if (e->type == ex_def) {
} else { t = e->e.def->type;
if (ftype->parm_types[i - 1] == &type_float } else {
&& e->type == ex_integer) { if (ftype->parm_types[i - 1] == &type_float
e->type = ex_float; && e->type == ex_integer) {
e->e.float_val = e->e.integer_val; e->type = ex_float;
} e->e.float_val = e->e.integer_val;
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);
arg_types[parm_count - i] = t; } else {
//if (e->type == ex_integer)
// warning (e, "passing integer consant into ... function");
} }
if (err) arg_types[parm_count - i] = t;
return err;
} else {
//for (e = e2; e; e = e->next)
// if (e->type == ex_integer)
// warning (e, "passing integer consant into ... function");
} }
if (err)
return err;
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++) {