ref: c19b3bf153c5a741945e1ed2681f2279dd0c7a28
parent: f9b1884ede4720f0d2e929784a0a4a37de05709e
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Sep 1 14:38:21 EDT 2015
Simplify all the constanst casts
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -40,7 +40,7 @@
if (r > RANK_UINT || tp == inttype || tp == uinttype)
return np;
tp = (r == RANK_UINT) ? uinttype : inttype;
- return node(OCAST, tp, np, NULL);
+ return convert(np, tp, 1);
}
static void
@@ -57,9 +57,9 @@
tp2 = np2->type;
if (tp1 != tp2) {
if ((n = tp1->n.rank - tp2->n.rank) > 0)
- np2 = node(OCAST, tp1, np2, NULL);
+ np2 = convert(np2, tp1, 1);
else if (n < 0)
- np1 = node(OCAST, tp2, np1, NULL);
+ np1 = convert(np1, tp2, 1);
}
*p1 = np1;
*p2 = np2;
@@ -270,7 +270,7 @@
switch (BTYPE(rp)) {
case INT:
if (rp->constant && SYMICMP(rp->sym, 0))
- rp = node(OCAST, pvoidtype, rp, NULL);
+ rp = convert(rp, pvoidtype, 1);
break;
case PTR:
if (lp->type != rp->type)
@@ -279,8 +279,7 @@
default:
errorp("incompatibles type in comparision");
}
-
- return node(op, inttype, lp, rp);
+ return simplify(op, inttype, lp, rp);
}
static Node *
@@ -404,7 +403,7 @@
if (BTYPE(rp) == INT && BTYPE(lp) == PTR &&
rp->constant && SYMICMP(rp->sym, 0)) {
- rp = node(OCAST, pvoidtype, rp, NULL);
+ rp = convert(rp, pvoidtype, 1);
} else if ((rp = convert(rp, lp->type, 0)) == NULL) {
errorp("incompatible types when assigning");
}
--- a/cc1/tests/test016.c
+++ b/cc1/tests/test016.c
@@ -20,7 +20,7 @@
L5
A4 G1 'P :P
A4 @I #I0 :I
- j L6 A4 #I0 IP !I
+ j L6 A4 #P0 !I
y #I1
L6
y #I0
@@ -34,10 +34,10 @@
A1 #I1 :I
A2 A1 'P :P
A4 A2 'P :P
- j L5 A2 #I0 IP =I
+ j L5 A2 #P0 =I
A4 @P @I #I0 :I
L5
- A2 #I0 IP :P
+ A2 #P0 :P
y A1
}
????