scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 53727b8e75d92fb88ac9916608e581e181d832c6
parent 2883d0179563960dacbe4c97ec78f3822aca7c29
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed,  7 Oct 2015 13:57:34 +0200

Fix cast between integer constants

Diffstat:
cc1/fold.c | 4++--
cc1/tests/test023.c | 4++--
cc1/tests/test024.c | 4++--
3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/cc1/fold.c b/cc1/fold.c @@ -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: @@ -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: @@ -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 @@ -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 @@ -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 @@ -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