*src/SDCCicode.c: fixed bug #1870216 - Error 122: dividing by zero
authorborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 13 Jan 2008 07:54:32 +0000 (07:54 +0000)
committerborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 13 Jan 2008 07:54:32 +0000 (07:54 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4992 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCicode.c

index db1f68bb2ad90da91442d2005be1a9c8551f314b..12700a1b7917dd5db0d84c97e9a5511f51852875 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,13 @@
 2008-01-13 Borut Razem <borut.razem AT siol.net>
 
        * support/scripts/sdcc.nsi: added Uninstall/reinstall page, ...
+       *src/SDCCicode.c: fixed bug #1870216 - Error 122: dividing by zero
+
+2007-12-30 Borut Razem <borut.razem AT siol.net>
+
+       * src/pic16/gen.c: fixed implementation of bitwise operations for
+         pic16targer
+       * support/regression/tests/bitwise.c: added test cases
 
 2007-12-29 Borut Razem <borut.razem AT siol.net>
 
index aa2c62cca3575625cea98c8ea2e19c396d2c81b7..1755276415f448ccbe38055e0006959d74ce0014 100644 (file)
@@ -1226,28 +1226,29 @@ operandOperation (operand * left, operand * right,
                                                    operandLitValue (right)));
       break;
     case '/':
-      if ((TYPE_TARGET_ULONG) double2ul (operandLitValue (right)) == 0)
+      if (IS_UNSIGNED (type))
         {
-          werror (E_DIVIDE_BY_ZERO);
-          retval = right;
-
+          if ((TYPE_TARGET_ULONG) double2ul (operandLitValue (right)) == 0)
+            {
+              werror (E_DIVIDE_BY_ZERO);
+              retval = right;
+            }
+          SPEC_USIGN (let) = 1;
+          SPEC_USIGN (ret) = 1;
+          retval = operandFromValue (valCastLiteral (type,
+                                    (TYPE_TARGET_ULONG) double2ul (operandLitValue (left)) /
+                                    (TYPE_TARGET_ULONG) double2ul (operandLitValue (right))));
         }
       else
         {
-          if (IS_UNSIGNED (type))
+          if (operandLitValue (right) == 0)
             {
-              SPEC_USIGN (let) = 1;
-              SPEC_USIGN (ret) = 1;
-              retval = operandFromValue (valCastLiteral (type,
-                                        (TYPE_TARGET_ULONG) double2ul (operandLitValue (left)) /
-                                        (TYPE_TARGET_ULONG) double2ul (operandLitValue (right))));
-            }
-          else
-            {
-              retval = operandFromValue (valCastLiteral (type,
-                                                     operandLitValue (left) /
-                                                     operandLitValue (right)));
+              werror (E_DIVIDE_BY_ZERO);
+              retval = right;
             }
+          retval = operandFromValue (valCastLiteral (type,
+                                                 operandLitValue (left) /
+                                                 operandLitValue (right)));
         }
       break;
     case '%':