From: epetrich Date: Tue, 9 Sep 2003 08:53:43 +0000 (+0000) Subject: * src/SDCCicode.c (geniCodeLogic): fixed bug #797572 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=ff00cfcd27b7a5648a406db0464bf39afcbe13df;p=fw%2Fsdcc * src/SDCCicode.c (geniCodeLogic): fixed bug #797572 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2882 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 6f0bdfb0..a58a0353 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2003-09-09 Erik Petrich + + * src/SDCCicode.c (geniCodeLogic): fixed bug #797572 + 2003-09-07 Erik Petrich * device/include/string.h: added size_t typedef, changed diff --git a/src/SDCCicode.c b/src/SDCCicode.c index 36a4837e..d62a96fe 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -1470,7 +1470,7 @@ operandFromSymbol (symbol * sym) ok && /* farspace check */ !IS_BITVAR (sym->etype) /* not a bit variable */ ) - { + { /* we will use it after all optimizations and before liveRange calculation */ @@ -2714,6 +2714,49 @@ geniCodeLogic (operand * left, operand * right, int op) OP_VALUE(right), "compare operation", 1); } + /* if one operand is a pointer and the other is a literal generic void pointer, + change the type of the literal generic void pointer to match the other pointer */ + if (IS_GENPTR (ltype) && IS_VOID (ltype->next) && IS_ITEMP (left) + && IS_PTR (rtype) && !IS_GENPTR(rtype)) + { + /* find left's definition */ + ic = (iCode *) setFirstItem (iCodeChain); + while (ic) + { + if (((ic->op == CAST) || (ic->op == '=')) + && isOperandEqual(left, IC_RESULT (ic))) + break; + else + ic = setNextItem (iCodeChain); + } + /* if casting literal to generic pointer, then cast to rtype instead */ + if (ic && (ic->op == CAST) && isOperandLiteral(IC_RIGHT (ic))) + { + left = operandFromValue (valCastLiteral (rtype, operandLitValue (IC_RIGHT (ic)))); + ltype = operandType(left); + } + } + if (IS_GENPTR (rtype) && IS_VOID (rtype->next) && IS_ITEMP (right) + && IS_PTR (ltype) && !IS_GENPTR(ltype)) + { + /* find right's definition */ + ic = (iCode *) setFirstItem (iCodeChain); + while (ic) + { + if (((ic->op == CAST) || (ic->op == '=')) + && isOperandEqual(right, IC_RESULT (ic))) + break; + else + ic = setNextItem (iCodeChain); + } + /* if casting literal to generic pointer, then cast to rtype instead */ + if (ic && (ic->op == CAST) && isOperandLiteral(IC_RIGHT (ic))) + { + right = operandFromValue (valCastLiteral (ltype, operandLitValue (IC_RIGHT (ic)))); + rtype = operandType(right); + } + } + ctype = usualBinaryConversions (&left, &right); ic = newiCode (op, left, right);