src/SDCCicode.c (ast2iCode): fixed differences in iCode with different compilers
authorbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 5 Sep 2003 22:14:44 +0000 (22:14 +0000)
committerbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 5 Sep 2003 22:14:44 +0000 (22:14 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2878 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCicode.c

index 414d399132c03af4bfe91fce5db798e4cd1e825f..f9607ef3609b9ff5f81ab8ff13eb72399eee4813 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2003-09-06  Bernhard Held <bernhard@bernhardheld.de>
+
+       * src/SDCCicode.c (ast2iCode): fixed differences in iCode with different
+       compilers
+
 2003-09-05  Erik Petrich <epetrich@ivorytower.norman.ok.us>
        * src/SDCCast.c (isConformingBody): fixed loop reversal bug
        reported in bug #800609
index abafe41ffb64f990d03481a4fce45809f17597a7..36a4837e9c89a5b7b2c4b0eb77fea7bfaebada77 100644 (file)
@@ -1097,9 +1097,9 @@ operandOperation (operand * left, operand * right,
                  ul != (TYPE_UWORD) ul)
                werror (W_INT_OVL);
            }
-         else /* int */
+         else /* signed int */
            {
-             /* int is handled here in order to detect overflow */
+             /* signed int is handled here in order to detect overflow */
              TYPE_DWORD l = (TYPE_WORD) operandLitValue (left) *
                             (TYPE_WORD) operandLitValue (right);
 
@@ -1989,8 +1989,8 @@ geniCodeDivision (operand * left, operand * right)
 
   resType = usualBinaryConversions (&left, &right);
 
-  /* if the right is a literal & power of 2 
-     and left is unsigned then make it a    
+  /* if the right is a literal & power of 2
+     and left is unsigned then make it a
      right shift */
   if (IS_LITERAL (retype) &&
       !IS_FLOAT (letype) &&
@@ -3656,9 +3656,21 @@ ast2iCode (ast * tree,int lvl)
     case NE_OP:
     case AND_OP:
     case OR_OP:
+      /* different compilers (even different gccs) evaluate
+        the two calls in a different order. to get the same
+        result on all machines we've to specify a clear sequence.
       return geniCodeLogic (geniCodeRValue (left, FALSE),
-                           geniCodeRValue (right, FALSE),
-                           tree->opval.op);
+                            geniCodeRValue (right, FALSE),
+                            tree->opval.op);
+      */
+      {
+       operand *leftOp, *rightOp;
+
+       rightOp = geniCodeRValue (right, FALSE);
+       leftOp  = geniCodeRValue (left , FALSE);
+
+       return geniCodeLogic (leftOp, rightOp, tree->opval.op);
+      }
     case '?':
       return geniCodeConditional (tree,lvl);