From: bernhardheld Date: Fri, 5 Sep 2003 22:14:44 +0000 (+0000) Subject: src/SDCCicode.c (ast2iCode): fixed differences in iCode with different compilers X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=18e57deddc09c124d5b86a1b79408c19c8aed7df;p=fw%2Fsdcc src/SDCCicode.c (ast2iCode): fixed differences in iCode with different compilers git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2878 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 414d3991..f9607ef3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-09-06 Bernhard Held + + * src/SDCCicode.c (ast2iCode): fixed differences in iCode with different + compilers + 2003-09-05 Erik Petrich * src/SDCCast.c (isConformingBody): fixed loop reversal bug reported in bug #800609 diff --git a/src/SDCCicode.c b/src/SDCCicode.c index abafe41f..36a4837e 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -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);