[hackers] [scc] Convert arithmetic() to use new type fields || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Fri, 8 Jan 2016 13:13:58 +0100 (CET)

commit 97f8f317d80776d196430997bea038e80709a206
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Jan 7 19:39:29 2016 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri Jan 8 10:49:29 2016 +0100

    Convert arithmetic() to use new type fields

diff --git a/cc1/expr.c b/cc1/expr.c
index 9a30c66..88a43c4 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
_AT_@ -320,28 +320,16 @@ incorrect:
 static Node *
 arithmetic(char op, Node *lp, Node *rp)
 {
- switch (BTYPE(lp)) {
- case INT:
- case FLOAT:
- switch (BTYPE(rp)) {
- case INT:
- case FLOAT:
- arithconv(&lp, &rp);
- break;
- case PTR:
- if (op == OADD || op == OSUB)
- return parithmetic(op, rp, lp);
- default:
- goto incorrect;
- }
- break;
- case PTR:
- return parithmetic(op, lp, rp);
- default:
- incorrect:
+ Type *ltp = lp->type, *rtp = rp->type;
+
+ if (ltp->arith && rtp->arith) {
+ arithconv(&lp, &rp);
+ } else if ((ltp->op == PTR || rtp->op == PTR) &&
+ op == OADD || op == OSUB) {
+ return parithmetic(op, rp, lp);
+ } else {
                 errorp("incorrect arithmetic operands");
         }
-
         return simplify(op, lp->type, lp, rp);
 }
 
Received on Fri Jan 08 2016 - 13:13:58 CET

This archive was generated by hypermail 2.3.0 : Fri Jan 08 2016 - 13:24:38 CET