shithub: scc

Download patch

ref: af498cdd3737f03a77ada5172fff1f727f463b10
parent: 8022f78f34e2b0532f880d2d64d363bb1e20531d
author: Roberto E. Vargas Caballero <[email protected]>
date: Sat Jul 18 06:53:02 EDT 2015

Fix constant calculation in node()

Non constant nodes make descendat non constant
independent of the other node, so we need &
and not |.

--- a/cc1/code.c
+++ b/cc1/code.c
@@ -321,14 +321,15 @@
 	np->op = op;
 	np->type = tp;
 	np->sym = NULL;
-	np->constant = np->symbol = np->lvalue = 0;
+	np->symbol = np->lvalue = 0;
+	np->constant = 1;
 	np->left = lp;
 	np->right = rp;
 
 	if (lp)
-		np->constant |= lp->constant;
+		np->constant &= lp->constant;
 	if (rp)
-		np->constant |= rp->constant;
+		np->constant &= rp->constant;
 
 	return np;
 }