[hackers] [scc] Fix cast between integer constants || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Wed, 7 Oct 2015 17:44:48 +0200 (CEST)

commit 53727b8e75d92fb88ac9916608e581e181d832c6
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Wed Oct 7 13:57:34 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Wed Oct 7 17:23:30 2015 +0200

    Fix cast between integer constants

diff --git a/cc1/fold.c b/cc1/fold.c
index 3a54d94..7d14a5c 100644
--- a/cc1/fold.c
+++ b/cc1/fold.c
_AT_@ -226,7 +226,7 @@ folduint(int op, Symbol *res, TUINT l, TUINT r)
         default: return 0;
         }
 
- res->u.u = u;
+ res->u.u = u & ones(res->type->size);
         return 1;
 
 sign:
_AT_@ -521,6 +521,7 @@ castcode(Node *np, Type *newtp)
                         u = (oldtp->sign) ? osym->u.i : osym->u.u;
                         break;
                 case FLOAT:
+ oldtp = newtp;
                         u = osym->u.f;
                         break;
                 default:
_AT_@ -529,7 +530,6 @@ castcode(Node *np, Type *newtp)
                 mask = ones(newtp->size);
                 if (newtp->sign) {
                         negmask = ~mask;
- u &= mask;
                         if (u & (negmask >> 1) & mask)
                                 u |= negmask;
                         aux.u.i = u;
diff --git a/cc1/tests/test023.c b/cc1/tests/test023.c
index 4a582e6..0401650 100644
--- a/cc1/tests/test023.c
+++ b/cc1/tests/test023.c
_AT_@ -13,7 +13,7 @@ A4 Z u
         A3 #W1 :W
         A3 #WFFFFFFFF :W
         A3 #WFFFFFFFF :W
- A3 #WFFFFFFFF :W
+ A3 #WFFFF :W
         A3 #WFFFFFFFF :W
         A3 #W3 :W
         A3 #W1 :W
_AT_@ -21,7 +21,7 @@ A4 Z u
         A4 #Z1 :Z
         A4 #ZFFFFFFFF :Z
         A4 #ZFFFFFFFF :Z
- A4 #ZFFFFFFFF :Z
+ A4 #ZFFFF :Z
         A4 #ZFFFFFFFF :Z
         A4 #Z3 :Z
         A4 #Z1 :Z
diff --git a/cc1/tests/test024.c b/cc1/tests/test024.c
index 89fa7cf..a4df3a1 100644
--- a/cc1/tests/test024.c
+++ b/cc1/tests/test024.c
_AT_@ -13,14 +13,14 @@ A4 O u
         A3 #Q1 :Q
         A3 #QFFFFFFFF :Q
         A3 #QFFFFFFFF :Q
- A3 #QFFFFFFFF :Q
+ A3 #QFFFF :Q
         A3 #QFFFFFFFF :Q
         A3 #Q3 :Q
         A3 #Q1 :Q
         A4 #O1 :O
         A4 #OFFFFFFFF :O
         A4 #OFFFFFFFF :O
- A4 #OFFFFFFFF :O
+ A4 #OFFFF :O
         A4 #OFFFFFFFF :O
         A4 #O3 :O
         A4 #O0 :O
Received on Wed Oct 07 2015 - 17:44:48 CEST

This archive was generated by hypermail 2.3.0 : Wed Oct 07 2015 - 17:48:24 CEST