shithub: scc

Download patch

ref: d299693e01b086035dec3b88125b526a8263d3cc
parent: bc320cfd01aa1f4d6fca750dac27cd13b5f49da1
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Oct 3 12:05:03 EDT 2016

[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.

--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
@@ -326,7 +326,7 @@
 	case OMEM:
 	case OAUTO:
 		*new = *np;
-		return np;
+		return new;
 	case OPTR:
 		return rhs(np->left, new);
 	case OFIELD:
@@ -590,7 +590,9 @@
 	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: