scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit b88cbb14faba53251ef025e788c69400ab17faec
parent adeca5a4f37c9dde9cd0fcd5f5bbc026c23db82f
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 14 Aug 2015 16:40:09 +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.

Diffstat:
Mcc1/expr.c | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/cc1/expr.c b/cc1/expr.c @@ -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); @@ -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));