fixed bug#680076
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 24 Feb 2003 15:32:12 +0000 (15:32 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 24 Feb 2003 15:32:12 +0000 (15:32 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2306 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCast.c

index fe878f9f29cda6b71acf43f0f1b849cdb0bb9496..4db1c15b6000e65ca99f3c446ae52214db7b6915 100644 (file)
@@ -2895,10 +2895,17 @@ decorateType (ast * tree)
       /* if they are pointers they must be castable */
       if (IS_PTR (LTYPE (tree)) && IS_PTR (RTYPE (tree)))
        {
+         if (tree->opval.op==EQ_OP && 
+             !IS_GENPTR(LTYPE(tree)) && IS_GENPTR(RTYPE(tree))) {
+           // we cannot cast a gptr to a !gptr: switch the leaves
+           struct ast *s=tree->left;
+           tree->left=tree->right;
+           tree->right=s;
+         }
          if (compareType (LTYPE (tree), RTYPE (tree)) == 0)
            {
              werror (E_COMPARE_OP);
-             fprintf (stderr, "comparing type ");
+             fprintf (stderr, "comparring type ");
              printTypeChain (LTYPE (tree), stderr);
              fprintf (stderr, "to type ");
              printTypeChain (RTYPE (tree), stderr);