ref: 0314a338f9488fafd0222ce35adf27fe6f4fec7d
parent: 354c8d23f2900601d620f23138b6dc433bb22f7d
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Jan 20 14:02:21 EST 2017
[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.
--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
@@ -229,7 +229,7 @@
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 @@
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 @@
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: