shithub: scc

Download patch

ref: cfe807ad6019b35141c53981f42e2289c66e9bb1
parent: e49575b22a7255b16d487a0a9e4a344caba77b9c
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Jun 17 11:18:16 EDT 2016

[cc2-qbe] Load parameters before calling functions

We were not loading the parameters, so it mean
that we were always passing pointers to the
parameters that were symbols.

--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
@@ -239,8 +239,10 @@
 	Type *tp = &np->type;
 	Node **q, *tmp, *p, *pars[NR_FUNPARAM];
 
-	for (n = 0, p = np->right; p; p = p->right)
-		pars[n++] = cgen(p->left);
+	for (n = 0, p = np->right; p; p = p->right) {
+		cgen(p->left);
+		pars[n++] = load(p, LOADL);
+	}
 
 	switch (tp->size) {
 	case 0: