[hackers] [scc] Fix eval() and exp2cond() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Fri, 14 Aug 2015 17:08:59 +0200 (CEST)

commit b88cbb14faba53251ef025e788c69400ab17faec
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri Aug 14 16:40:09 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri Aug 14 16:40:09 2015 +0200

    Fix eval() and exp2cond()
    
    Eval() was checking only with logical operators, but it should
    check against relational operators to.
    Exp2cond() was not decaying pointers.

diff --git a/cc1/expr.c b/cc1/expr.c
index 35a4394..a85dc91 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
_AT_@ -291,7 +291,7 @@ eval(Node *np)
         case FTN:
                 np = decay(np);
         }
- if (np->op != OAND && np->op != OOR)
+ if (!isnodecmp(np->op))
                 return np;
         p = node(OCOLON, inttype, constnode(one), constnode(zero));
         return node(OASK, inttype, np, p);
_AT_@ -562,6 +562,11 @@ negate(Node *np)
 static Node *
 exp2cond(Node *np, char neg)
 {
+ switch (BTYPE(np)) {
+ case ARY:
+ case FTN:
+ np = decay(np);
+ }
         if (isnodecmp(np->op))
                 return (neg) ? negate(np) : np;
         return compare(ONE ^ neg, np, constnode(zero));
Received on Fri Aug 14 2015 - 17:08:59 CEST

This archive was generated by hypermail 2.3.0 : Fri Aug 14 2015 - 17:12:26 CEST