commit d9b9cf2c66cd52605ddbac816cd204daf3f4a4cf
parent 204960d4e839953472c11204ea6b2e893019cc0e
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Mon, 3 Oct 2016 16:05:03 +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.
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c
@@ -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:
@@ -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: