[hackers] [scc] Simplify all the constanst casts || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Tue, 1 Sep 2015 18:41:10 +0200 (CEST)

commit c19b3bf153c5a741945e1ed2681f2279dd0c7a28
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Sep 1 18:38:21 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Tue Sep 1 18:38:21 2015 +0200

    Simplify all the constanst casts

diff --git a/cc1/expr.c b/cc1/expr.c
index d7dacc0..777b72c 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
_AT_@ -40,7 +40,7 @@ promote(Node *np)
         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
_AT_@ -57,9 +57,9 @@ typeconv(Node **p1, Node **p2)
         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;
_AT_@ -270,7 +270,7 @@ pcompare(char op, Node *lp, Node *rp)
         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)
_AT_@ -279,8 +279,7 @@ pcompare(char op, Node *lp, Node *rp)
         default:
                 errorp("incompatibles type in comparision");
         }
-
- return node(op, inttype, lp, rp);
+ return simplify(op, inttype, lp, rp);
 }
 
 static Node *
_AT_@ -404,7 +403,7 @@ assignop(char op, Node *lp, Node *rp)
 
         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");
         }
diff --git a/cc1/tests/test016.c b/cc1/tests/test016.c
index 850fae1..106c024 100644
--- a/cc1/tests/test016.c
+++ b/cc1/tests/test016.c
_AT_@ -20,7 +20,7 @@ A4 P p
 L5
         A4 G1 'P :P
         A4 _AT_I #I0 :I
- j L6 A4 #I0 IP !I
+ j L6 A4 #P0 !I
         y #I1
 L6
         y #I0
_AT_@ -34,10 +34,10 @@ A4 P pp
         A1 #I1 :I
         A2 A1 'P :P
         A4 A2 'P :P
- j L5 A2 #I0 IP =I
+ j L5 A2 #P0 =I
         A4 _AT_P @I #I0 :I
 L5
- A2 #I0 IP :P
+ A2 #P0 :P
         y A1
 }
 ????
Received on Tue Sep 01 2015 - 18:41:10 CEST

This archive was generated by hypermail 2.3.0 : Tue Sep 01 2015 - 18:48:13 CEST