aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'bootstrap/parse.c')
-rw-r--r--bootstrap/parse.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/bootstrap/parse.c b/bootstrap/parse.c
index 9c6f5a8..d55339d 100644
--- a/bootstrap/parse.c
+++ b/bootstrap/parse.c
@@ -940,22 +940,27 @@ pexpostfix(struct parser *P) {
for (;;) if (lexmatch(P, &tok, '(')) {
vec_t(struct expr) args = {0};
- int i = 0, n = ex.ty->fn.params.n;
+ const struct type *ty = ex.ty;
+ int i = 0;
+
+ if (ty->t == TYptr)
+ ty = ty->child;
- if (ex.ty->t != TYfn)
- fatal(P, ex.span, "callee is not a function (is %t)", ex.ty);
+ if (ty->t != TYfn)
+ fatal(P, ex.span, "callee is not a function (is %t)", ty);
while (!lexmatch(P, NULL, ')')) {
+ int n = ty->fn.params.n;
struct expr arg;
- if (i == n && ! ex.ty->fn.variadic)
+ if (i == n && ! ty->fn.variadic)
fatal(P, arg.span, "too many args for call: (expected %d)", n);
if (i < n)
- P->targty = ex.ty->fn.params.d[i];
+ P->targty = ty->fn.params.d[i];
arg = parseexpr(P);
- if (i < n && !typeof2(arg.ty, ex.ty->fn.params.d[i++]))
+ if (i < n && !typeof2(arg.ty, ty->fn.params.d[i++]))
fatal(P, arg.span,
"call argument #%d type mismatch (%t, expected %t)",
- i, arg.ty, ex.ty->fn.params.d[i - 1]);
+ i, arg.ty, ty->fn.params.d[i - 1]);
vec_push(&args, arg);
if (!lexmatch(P, NULL, ',')) {
@@ -966,7 +971,7 @@ pexpostfix(struct parser *P) {
ex.call.callee = exprdup(ex);
ex.t = Ecall;
ex.span = tok.span;
- ex.ty = ex.call.callee->ty->fn.retty;
+ ex.ty = ty->fn.retty;
vec_slice_cpy(&ex.call.args, &args);
} else if (lexmatch(P, &tok, '[')) {
struct expr lhs = ex,