scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 9f59d4ee73fec3d84d1bff6b2938c9972107250d
parent f4f53c76d3704a8c458c2cc861e73fdd6f9f84ea
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 20 Jan 2017 19:02:21 +0100

[cc2-qbe] Fix calls using function pointers

Call() needs an additional parameter, because the calling address
maybe is not the left pointer of np if we are using function
pointers.

Diffstat:
Mcc2/arch/qbe/cgen.c | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c @@ -229,7 +229,7 @@ cast(Type *td, Node *ns, Node *nd) static Node *rhs(Node *np, Node *new); static Node * -call(Node *np, Node *ret) +call(Node *np, Node *fun, Node *ret) { int n, op; Type *tp; @@ -259,7 +259,7 @@ call(Node *np, Node *ret) default: abort(); } - code(op, tmpnode(ret, tp), np->left, NULL); + code(op, tmpnode(ret, tp), fun, NULL); for (q = pars; q < &pars[n]; ++q) { op = (q == &pars[n-1]) ? ASPARE : ASPAR; @@ -553,8 +553,8 @@ rhs(Node *np, Node *ret) return ret; case OCALL: if (l->op == OPTR) - np = rhs(l, &aux1); - return call(np, ret); + l = rhs(l, &aux1); + return call(np, l, ret); case OCAST: return cast(tp, rhs(l, &aux1), ret); case OASSIG: