]> git.gag.com Git - fw/sdcc/commitdiff
* src/SDCCicode.c (geniCodeLogic): fixed bug #797572
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 9 Sep 2003 08:53:43 +0000 (08:53 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 9 Sep 2003 08:53:43 +0000 (08:53 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2882 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCicode.c

index 6f0bdfb038a30fc758ff49e62e5cc4d6989366db..a58a0353ab8d783a0a8f80459b3275f0bd7b405b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2003-09-09  Erik Petrich <epetrich@ivorytower.norman.ok.us>
+
+       * src/SDCCicode.c (geniCodeLogic): fixed bug #797572
+
 2003-09-07  Erik Petrich <epetrich@ivorytower.norman.ok.us>
 
        * device/include/string.h: added size_t typedef, changed
index 36a4837e9c89a5b7b2c4b0eb77fea7bfaebada77..d62a96fe8281e78aeed1497e177b672ed756cf05 100644 (file)
@@ -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);