[hackers] [scc] [cc2-qbe] Fix lhs() and OADDR || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 3 Oct 2016 16:07:27 +0200 (CEST)

commit d9b9cf2c66cd52605ddbac816cd204daf3f4a4cf
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Oct 3 16:05:03 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Oct 3 16:05:03 2016 +0200

    [cc2-qbe] Fix lhs() and OADDR
    
    lhs was returning the source node instead of returning the destination
    node, and it was hidden the error because the correct type of the
    lhs expression is the type of the parent when we are in a OADDR
    expression. Without this patch pointers passed as parameters had the
    same type that the base type instead of having pointer type.

diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c
index 425fd74..3deb1e4 100644
--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
_AT_@ -326,7 +326,7 @@ lhs(Node *np, Node *new)
         case OMEM:
         case OAUTO:
                 *new = *np;
- return np;
+ return new;
         case OPTR:
                 return rhs(np->left, new);
         case OFIELD:
_AT_@ -590,7 +590,9 @@ rhs(Node *np, Node *ret)
         case OPTR:
                 return load(tp, rhs(l, &aux1), ret);
         case OADDR:
- return lhs(l, ret);
+ lhs(l, ret);
+ ret->type = *tp;
+ return ret;
         case OFIELD:
                 return field(np, ret, 0);
         default:
Received on Mon Oct 03 2016 - 16:07:27 CEST

This archive was generated by hypermail 2.3.0 : Mon Oct 03 2016 - 16:12:14 CEST