ref: befd4b3ef6de5f64ba923e2b0b86e46609e7e1fd
parent: b88cbb14faba53251ef025e788c69400ab17faec
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Aug 14 12:48:21 EDT 2015
simplify calls to decay() It was common check the type of the node before calling decay(), so it is a good idea put this test inside of decay() itself. The call to decay() in negation() was not needed anymore because exp2cond() calls to decay().
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -272,8 +272,14 @@
{
Type *tp = np->type;
- if (tp->op == ARY)
+ switch (tp->op) {
+ case ARY:
tp = tp->type;
+ case FTN:
+ break;
+ default:
+ return np;
+ }
return node(OADDR, mktype(tp, PTR, 0, NULL), np, NULL);
}
@@ -286,11 +292,7 @@
if (!np)
return NULL;
- switch (BTYPE(np)) {
- case ARY:
- case FTN:
- np = decay(np);
- }
+ np = decay(np);
if (!isnodecmp(np->op))
return np;
p = node(OCOLON, inttype, constnode(one), constnode(zero));
@@ -562,11 +564,7 @@
static Node *
exp2cond(Node *np, char neg)
{
- switch (BTYPE(np)) {
- case ARY:
- case FTN:
- np = decay(np);
- }
+ np = decay(np);
if (isnodecmp(np->op))
return (neg) ? negate(np) : np;
return compare(ONE ^ neg, np, constnode(zero));
@@ -695,7 +693,6 @@
switch (BTYPE(np)) {
case FTN:
case ARY:
- np = decay(np);
case INT:
case FLOAT:
case PTR: