shithub: scc

Download patch

ref: 7dbe07d804e83477fa7231567c09f74612f6aa39
parent: 7fba4ee75f2cfe1c2988e49bfa9158594503e678
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Feb 3 10:11:48 EST 2017

[cc2-qbe] Handle left casts in abbreviations

Due to the difference of sizes it is possible to have casts in
the lhs part of an expression, which must be handle out of
lhs(), because it is only due to the double meaning of
abbreviations (being a lhs() and rhs()).

--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
@@ -563,6 +563,15 @@
 			aux2.right = np->right;
 			aux2.left = np->left;
 			r = rhs(&aux2, &aux1);
+			Node aux3;
+			if (l->op == OCAST) {
+				aux3.type = l->left->type;
+				aux3.op = OCAST;
+				aux3.left = r;
+				aux3.right = NULL;
+				r = &aux3;
+				l = l->left;
+			}
 		case 0:
 			/* TODO: see what is the most difficult */
 			lhs(l, &aux2);