* src/SDCCval.h: unified double2ul macro for all platforms
authorborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 2 Oct 2007 19:48:15 +0000 (19:48 +0000)
committerborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 2 Oct 2007 19:48:15 +0000 (19:48 +0000)
* 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
src/SDCCval.c
support/regression/tests/bitwise.c

index ec342a2a8503931bd546f684f79b9c3c730cdcc7..32159fe9c36b63989430ca5360c0e7d355545bb7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
 2007-10-02 Borut Razem <borut.razem AT siol.net>
 
        * 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 <borut.razem AT siol.net>
 
index 82050fc3618590c4df318f3badc57ee3cabf54db..424d918a136cbbf871cbca8e88e735edc02e696e 100644 (file)
@@ -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:
index 2a2851aad210dd2314337ab5f3ddc4b1b90d44a2..7982be71f3c23ff79e40fcc19ca81419cf3bfff5 100644 (file)
@@ -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);
+}