* src/SDCCast.c: fix #498138 by Johan
authorbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 2 Jan 2002 22:54:25 +0000 (22:54 +0000)
committerbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 2 Jan 2002 22:54:25 +0000 (22:54 +0000)
* src/SDCCglue.c: fix #498138 by Johan

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1756 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCast.c
src/SDCCglue.c

index ba4ad491ed229757b48a649a1270a1d7cf239d11..aed8131a112e2165c349117080b88e031db6ce66 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-01-02  Bernhard Held  <bernhard@bernhardheld.de>
+
+       * src/SDCCast.c: fix #498138 by Johan
+
+       * src/SDCCglue.c: fix #498138 by Johan
+
 2001-01-02  Bernhard Held  <bernhard@bernhardheld.de>
 
        * support/regression/Makefile: fix clean
index 26cd0353fc5f154fa3db4b351c127390a5869e36..85ea2852e1b4b6287e8297b2f2eb58e6fa71c9be 100644 (file)
@@ -1236,9 +1236,9 @@ constExprValue (ast * cexpr, int check)
       /* if we are casting a literal value then */
       if (IS_AST_OP (cexpr) &&
          cexpr->opval.op == CAST &&
-         IS_LITERAL (cexpr->left->ftype))
+         IS_LITERAL (cexpr->right->ftype))
        return valCastLiteral (cexpr->ftype,
-                              floatFromVal (cexpr->left->opval.val));
+                              floatFromVal (cexpr->right->opval.val));
 
       if (IS_AST_VALUE (cexpr))
        return cexpr->opval.val;
@@ -3095,13 +3095,8 @@ decorateType (ast * tree)
       if (compareType (LTYPE (tree), RTYPE (tree)) == 0)
        {
          werror (E_TYPE_MISMATCH, "assignment", " ");
-         fprintf (stderr, "type --> '");
-         printTypeChain (RTYPE (tree), stderr);
-         fprintf (stderr, "' ");
-         fprintf (stderr, "assigned to type --> '");
-         printTypeChain (LTYPE (tree), stderr);
-         fprintf (stderr, "'\n");
-         goto errorTreeReturn;
+         printFromToType(RTYPE(tree),LTYPE(tree));
+         //goto errorTreeReturn;
        }
 
       /* if the left side of the tree is of type void
index 748f6848b1f95b9984461838f145ea2d5bb9da3a..208900340a4812f2920fa37ee4e3fbca4cfc4917 100644 (file)
@@ -794,6 +794,16 @@ printIvalFuncPtr (sym_link * type, initList * ilist, FILE * oFile)
   int dLvl = 0;
 
   val = list2val (ilist);
+
+  if (IS_LITERAL(val->etype)) {
+    if (compareType(type,val->etype)==0) {
+      werror (E_INCOMPAT_TYPES);
+      printFromToType (val->type, type);
+    }
+    printIvalCharPtr (NULL, type, val, oFile);
+    return;
+  }
+
   /* check the types   */
   if ((dLvl = compareType (val->type, type->next)) <= 0)
     {
@@ -893,8 +903,8 @@ printIvalCharPtr (symbol * sym, sym_link * type, value * val, FILE * oFile)
                      aopLiteral (val, 0), aopLiteral (val, 1));
          break;
        case 3:
-         // mcs51 generic pointer
-         if (floatFromVal(val)!=0) {
+         if (IS_GENPTR(type) && floatFromVal(val)!=0) {
+           // non-zero mcs51 generic pointer
            werror (E_LITERAL_GENERIC);
          }
          fprintf (oFile, "\t.byte %s,%s,%s\n",
@@ -903,8 +913,8 @@ printIvalCharPtr (symbol * sym, sym_link * type, value * val, FILE * oFile)
                   aopLiteral (val, 2));
          break;
        case 4:
-         // ds390 generic pointer
-         if (floatFromVal(val)!=0) {
+         if (IS_GENPTR(type) && floatFromVal(val)!=0) {
+           // non-zero ds390 generic pointer
            werror (E_LITERAL_GENERIC);
          }
          fprintf (oFile, "\t.byte %s,%s,%s,%s\n",