From 7d543f6990526964cc8c495a9b596de60bfd9e4e Mon Sep 17 00:00:00 2001 From: borutr Date: Tue, 2 Oct 2007 19:48:15 +0000 Subject: [PATCH] * src/SDCCval.h: unified double2ul macro for all platforms * src/SDCCval.c: fixed bug #1777758 - applied Maarten's patch * support/regression/tests/bitwise.c: added regtest for bug #1777758 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4926 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 2 ++ src/SDCCval.c | 7 +++++-- support/regression/tests/bitwise.c | 10 ++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ec342a2a..32159fe9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2007-10-02 Borut Razem * src/SDCCval.h: unified double2ul macro for all platforms + * src/SDCCval.c: fixed bug #1777758 - applied Maarten's patch + * support/regression/tests/bitwise.c: added regtest for bug #1777758 2007-09-30 Borut Razem diff --git a/src/SDCCval.c b/src/SDCCval.c index 82050fc3..424d918a 100644 --- a/src/SDCCval.c +++ b/src/SDCCval.c @@ -1824,8 +1824,11 @@ valCastLiteral (sym_link * dtype, double fval) break; case V_BITFIELD: - SPEC_CVAL (val->etype).v_uint = ((TYPE_TARGET_UINT) l) & - (0xffffu >> (16 - SPEC_BLEN (val->etype))); + l &= (0xffffffffu >> (32 - SPEC_BLEN (val->etype))); + if (SPEC_USIGN (val->etype)) + SPEC_CVAL (val->etype).v_uint = (TYPE_TARGET_UINT) l; + else + SPEC_CVAL (val->etype).v_int = (TYPE_TARGET_INT) l; break; case V_CHAR: diff --git a/support/regression/tests/bitwise.c b/support/regression/tests/bitwise.c index 2a2851aa..7982be71 100644 --- a/support/regression/tests/bitwise.c +++ b/support/regression/tests/bitwise.c @@ -36,3 +36,13 @@ testTwoOpBitwise(void) ASSERT(({type})(~left) == ({type})0xFFFFC208); #endif } + +static void +testBug_1777758(void) +{ + char ep = -1; + + ep &= ~0x80; + + ASSERT(ep == 127); +} -- 2.47.2