[hackers] [scc] Fix promote() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Thu, 3 Sep 2015 18:00:48 +0200 (CEST)

commit 9b8d4f081969cb22e1a127c690e943b8247e5594
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Sep 3 17:57:36 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Thu Sep 3 17:57:36 2015 +0200

    Fix promote()
    
    Promote is called in different places to ensure that the integer type promotion
    is done, but it may be called with no integer nodes, and convert() returns
    NULL in this case, so a test is needed.

diff --git a/cc1/expr.c b/cc1/expr.c
index 3e1dffa..4611721 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
_AT_@ -50,6 +50,7 @@ static Node *
 promote(Node *np)
 {
         Type *tp;
+ Node *new;
         unsigned r;
 
         tp = np->type;
_AT_@ -57,7 +58,9 @@ promote(Node *np)
         if (r > RANK_UINT || tp == inttype || tp == uinttype)
                 return np;
         tp = (r == RANK_UINT) ? uinttype : inttype;
- return convert(np, tp, 1);
+ if ((new = convert(np, tp, 1)) != NULL)
+ return new;
+ return np;
 }
 
 static void
Received on Thu Sep 03 2015 - 18:00:48 CEST

This archive was generated by hypermail 2.3.0 : Thu Sep 03 2015 - 18:12:12 CEST