[hackers] [scc] Fix constant calculation in node() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sat, 18 Jul 2015 10:56:27 +0200 (CEST)

commit af498cdd3737f03a77ada5172fff1f727f463b10
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Sat Jul 18 10:53:02 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Sat Jul 18 10:53:02 2015 +0200

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

diff --git a/cc1/code.c b/cc1/code.c
index 1d28b62..e5ee575 100644
--- a/cc1/code.c
+++ b/cc1/code.c
_AT_@ -321,14 +321,15 @@ node(unsigned op, Type *tp, Node *lp, Node *rp)
         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;
 }
Received on Sat Jul 18 2015 - 10:56:27 CEST

This archive was generated by hypermail 2.3.0 : Sat Jul 18 2015 - 11:00:13 CEST