scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 7c9e9d8479731a93dbbd18a06877b32f282d113e
parent a794c4b02bb81b0b563d579a46bc25cf42582352
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat,  4 Feb 2017 21:57:22 +0100

[cc1] Remove negate()

This function remained from a time were cc1 had a different way
(and wrong) of implementing negation. It is a non sense now.

Diffstat:
Mcc1/expr.c | 42++++++------------------------------------
1 file changed, 6 insertions(+), 36 deletions(-)

diff --git a/cc1/expr.c b/cc1/expr.c @@ -408,57 +408,27 @@ negop(int op) return op; } -Node * -negate(Node *np) -{ - int op = np->op; - - switch (np->op) { - case OSYM: - assert(np->flags&NCONST && np->type->prop&TINTEGER); - np->sym = (np->sym->u.i) ? zero : one; - break; - case OOR: - case OAND: - if (np->op == ONEG) { - Node *new = np->left; - free(np); - return new; - } - np = node(ONEG, inttype, np, NULL); - break; - case OEQ: - case ONE: - case OLT: - case OGE: - case OLE: - case OGT: - np->op = negop(op); - break; - default: - abort(); - } - - return np; -} - static Node * -exp2cond(Node *np, char neg) +exp2cond(Node *np, int neg) { if (np->type->prop & TAGGREG) { errorp("used struct/union type value where scalar is required"); return constnode(zero); } switch (np->op) { + case ONEG: case OOR: case OAND: + return node(ONEG, inttype, np, NULL); case OEQ: case ONE: case OLT: case OGE: case OLE: case OGT: - return (neg) ? negate(np) : np; + if (neg) + np->op = negop(np->op); + return np; default: return compare((neg) ? OEQ : ONE, np, constnode(zero)); }