scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit d48fb010d5772ec6a3c9620a5c763f6d3e36de84
parent 5654476dce2255a26d4082d273fa4b654ae2513a
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  8 Jan 2016 12:48:03 +0100

Convert negation() to use the new fields in type

Diffstat:
cc1/expr.c | 15++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/cc1/expr.c b/cc1/expr.c @@ -551,16 +551,13 @@ address(char op, Node *np) static Node * negation(char op, Node *np) { - switch (BTYPE(np)) { - case FTN: - case ARY: - case INT: - case FLOAT: - case PTR: - return exp2cond(np, 1); - default: - error("invalid argument of unary '!'"); + np = decay(np); + if (!np->type->arith && np->type->op != PTR) { + errorp("invalid argument of unary '!'"); + freetree(np); + return constnode(zero); } + return exp2cond(np, 1); } static Symbol *