undid the fix for bug #455597, there has to be a better way
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 17 Sep 2001 13:27:17 +0000 (13:27 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 17 Sep 2001 13:27:17 +0000 (13:27 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1279 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCast.c
src/SDCCcse.c

index 8399cca05515f48b8c302fd624a054cc044310d6..7606c13d87e49eb2a06357bf66a7f176ab63ef62 100644 (file)
@@ -2761,6 +2761,7 @@ decorateType (ast * tree)
       /* make sure the type is complete and sane */
       checkTypeSanity(LETYPE(tree), "(cast)");
 
+#if 0
       /* if the right is a literal replace the tree */
       if (IS_LITERAL (RETYPE (tree))) {
              if (!IS_PTR (LTYPE (tree))) {
@@ -2788,6 +2789,22 @@ decorateType (ast * tree)
              TTYPE (tree) = LTYPE (tree);
              LRVAL (tree) = 1;
       }
+#else
+      /* if the right is a literal replace the tree */
+      if (IS_LITERAL (RETYPE (tree)) && !IS_PTR (LTYPE (tree))) {
+       tree->type = EX_VALUE;
+       tree->opval.val =
+         valCastLiteral (LTYPE (tree),
+                         floatFromVal (valFromType (RETYPE (tree))));
+       tree->left = NULL;
+       tree->right = NULL;
+       TTYPE (tree) = tree->opval.val->type;
+       tree->values.literalFromCast = 1;
+      } else {
+       TTYPE (tree) = LTYPE (tree);
+       LRVAL (tree) = 1;
+      }
+#endif
 
       TETYPE (tree) = getSpec (TTYPE (tree));
 
index 45a0aef708ffb048489b391d6b610f53c41f9b08..7d1de84be8631cbe2286e244b95321e6a58aee12 100644 (file)
@@ -326,16 +326,6 @@ DEFSETFUNC (findCheaperOp)
          (*opp)->isaddr = cop->isaddr;
        }
 
-      if ((*opp)->type==VALUE && 
-         IS_SYMOP(cop) && IS_GENPTR(OP_SYMBOL(cop)->type)) {
-       // This is a value assigned to a gpointer
-       if (1) {
-         // this value is used for a cast, so we can not
-         *opp=NULL;
-         return 0;
-       }       
-      }
-
       return 1;
 
     }