[hackers] [scc] [cc2-qbe] Fix calls using function pointers || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Fri, 20 Jan 2017 19:09:43 +0100 (CET)

commit 9f59d4ee73fec3d84d1bff6b2938c9972107250d
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri Jan 20 19:02:21 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri Jan 20 19:02:21 2017 +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.

diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c
index 7c48a40..da574ff 100644
--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
_AT_@ -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;
_AT_@ -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;
_AT_@ -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:
Received on Fri Jan 20 2017 - 19:09:43 CET

This archive was generated by hypermail 2.3.0 : Fri Jan 20 2017 - 19:12:18 CET