From 40cd81581d14260eb0d90bfe460ad0b2af38c9ca Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Sat, 31 Oct 2026 17:24:18 +0100 Subject: call.c: Fix find prototype --- src/prc1/call.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'src/prc1') diff --git a/src/prc1/call.c b/src/prc1/call.c index 41dde47..e6db4ca 100644 --- a/src/prc1/call.c +++ b/src/prc1/call.c @@ -142,13 +142,28 @@ void call_free(struct call *c) free(c->params); } -static const struct pr *find(const struct ast *ast, const char *s) +static const struct pr *find_proto(const struct fn *fn, const char *tr, + const char *s) +{ + const struct type *t = type_find(fn, tr, s); + + if (t && t->type == P) + return t->u.p.fn->pr; + + return NULL; +} + +static const struct pr *find(const struct ast *ast, const char *tr, + const char *s) { for (size_t i = 0; i < ast->nfns; i++) { const struct fn *fn = &ast->fns[i]; + const struct pr *pr; - if (!strcmp(fn->tk->s, s)) + if ((pr = find_proto(fn, tr, s))) + return pr; + else if (!strcmp(fn->tk->s, s)) return fn->pr; } @@ -161,10 +176,16 @@ static int onsym(const struct lex *l, struct prv *p, const struct sym *s) struct stmt *stmt = stmt_cur(p); struct call *c = &stmt->u.call; const struct tk *tk = s->tk; - const struct pr *pr = find(p->ast, tk->s); + const char *tr = triplet(p); + const struct pr *pr; const struct stentry *e; - if (pr) + if (!tr) + { + fprintf(stderr, "%s: unreachable\n", __func__); + return -1; + } + else if ((pr = find(p->ast, tr, tk->s))) c->pr = pr; else if (!(e = fn_var(fn, tk))) { -- cgit v1.2.3