* src/SDCCicode.c (geniCodeAdd),
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 13 Dec 2003 06:56:07 +0000 (06:56 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 13 Dec 2003 06:56:07 +0000 (06:56 +0000)
* src/SDCCast.c (decorateType): fixed bug #857753 (need to be careful
with valFromType if type might be a pointer and host is big endian).
* src/SDCCast.c (decorateType): unary plus compatible with all arithmetic
types, not just integer types.
* src/SDCCsymt.c (addSymChain): clarified error message when symbol is
multiply defined with mismatching "at" address.

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

ChangeLog
src/SDCCast.c
src/SDCCicode.c
src/SDCCsymt.c

index 4178725c8f2fc676ae4058f36eeb49b548708d28..236d8ee31bee171866c6ab050e26893a8c2a9598 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2003-12-13 Erik Petrich <epetrich@ivorytower.norman.ok.us>
+
+       * src/SDCCicode.c (geniCodeAdd),
+       * src/SDCCast.c (decorateType): fixed bug #857753 (need to be careful
+       with valFromType if type might be a pointer and host is big endian).
+       * src/SDCCast.c (decorateType): unary plus compatible with all arithmetic
+       types, not just integer types. 
+       * src/SDCCsymt.c (addSymChain): clarified error message when symbol is
+       multiply defined with mismatching "at" address.
+
 2003-12-12 Erik Petrich <epetrich@ivorytower.norman.ok.us>
 
        * src/ds390/main.c (PORT tininative_port): fixed bug #858416
index 3ad209808c7b92cf87df7308aff8e0b166eb6af3..0a289dbede28214a505a5711773b8c63afc9bbe9 100644 (file)
@@ -2776,7 +2776,7 @@ decorateType (ast * tree)
       /* if unary plus */
       if (!tree->right)
        {
-         if (!IS_INTEGRAL (LTYPE (tree)))
+         if (!IS_ARITHMETIC (LTYPE (tree)))
            {
              werror (E_UNARY_OP, '+');
              goto errorTreeReturn;
@@ -3249,7 +3249,7 @@ decorateType (ast * tree)
          tree->opval.val = valCastLiteral (
            LTYPE (tree),
            element->offset
-            + floatFromVal (valFromType (RETYPE (tree->right->left->left)))
+            + floatFromVal (valFromType (RTYPE (tree->right->left->left)))
           );
 
          TTYPE (tree) = tree->opval.val->type;
@@ -3285,7 +3285,7 @@ decorateType (ast * tree)
           sym->cdef = 1;
           sym->isref = 1;
           SPEC_STAT (sym->etype) = 1;
-          SPEC_ADDR(sym->etype) = floatFromVal (valFromType (RETYPE (tree)));
+          SPEC_ADDR(sym->etype) = floatFromVal (valFromType (RTYPE (tree)));
           SPEC_ABSA(sym->etype) = 1;
           addSym (SymbolTab, sym, sym->name, 0, 0, 0);
           allocGlobal (sym);
@@ -3303,7 +3303,7 @@ decorateType (ast * tree)
          tree->type = EX_VALUE;
          tree->opval.val =
          valCastLiteral (LTYPE (tree),
-                         floatFromVal (valFromType (RETYPE (tree))));
+                         floatFromVal (valFromType (RTYPE (tree))));
          TTYPE (tree) = tree->opval.val->type;
          tree->left = NULL;
          tree->right = NULL;
@@ -3348,8 +3348,8 @@ decorateType (ast * tree)
          IS_LITERAL (LTYPE (tree)))
        {
          tree->type = EX_VALUE;
-         tree->opval.val = valLogicAndOr (valFromType (LETYPE (tree)),
-                                          valFromType (RETYPE (tree)),
+         tree->opval.val = valLogicAndOr (valFromType (LTYPE (tree)),
+                                          valFromType (RTYPE (tree)),
                                           tree->opval.op);
          tree->right = tree->left = NULL;
          TETYPE (tree) = getSpec (TTYPE (tree) =
@@ -3390,7 +3390,7 @@ decorateType (ast * tree)
          if (compareType (LTYPE (tree), RTYPE (tree)) == 0)
            {
              werror (E_COMPARE_OP);
-             fprintf (stderr, "comparring type ");
+             fprintf (stderr, "comparing type ");
              printTypeChain (LTYPE (tree), stderr);
              fprintf (stderr, "to type ");
              printTypeChain (RTYPE (tree), stderr);
index 53efa92caf1f8eb356e4c80482e908a691aa8b77..9637d52dd11313e42b2129658c337727efd3e67e 100644 (file)
@@ -2176,11 +2176,11 @@ geniCodeAdd (operand * left, operand * right, int lvl)
 
   /* if the right side is LITERAL zero */
   /* return the left side              */
-  if (IS_LITERAL (retype) && right->isLiteral && !floatFromVal (valFromType (retype)))
+  if (IS_LITERAL (retype) && right->isLiteral && !floatFromVal (valFromType (rtype)))
     return left;
 
   /* if left is literal zero return right */
-  if (IS_LITERAL (letype) && left->isLiteral && !floatFromVal (valFromType (letype)))
+  if (IS_LITERAL (letype) && left->isLiteral && !floatFromVal (valFromType (ltype)))
     return right;
 
   /* if left is a pointer then size */
@@ -2202,8 +2202,8 @@ geniCodeAdd (operand * left, operand * right, int lvl)
   /* if they are both literals then we know */
   if (IS_LITERAL (letype) && IS_LITERAL (retype)
       && left->isLiteral && right->isLiteral)
-    return operandFromValue (valPlus (valFromType (letype),
-                                     valFromType (retype)));
+    return operandFromValue (valPlus (valFromType (ltype),
+                                     valFromType (rtype)));
 
   ic = newiCode ('+', left, right);
 
index f68a60e57c48fdc6055d9d004abceb32f74c6c00..14bcaee6f72dd93fbdc313ad35100c7c783f183c 100644 (file)
@@ -1000,6 +1000,23 @@ addSymChain (symbol * symHead)
              DCL_ELEM(csym->type) = DCL_ELEM(sym->type);
          }
 
+       #if 0
+       /* If only one of the definitions used the "at" keyword, copy */
+       /* the address to the other. */
+       if (IS_SPEC(csym->etype) && SPEC_ABSA(csym->etype)
+           && IS_SPEC(sym->etype) && !SPEC_ABSA(sym->etype))
+         {
+           SPEC_ABSA (sym->etype) = 1;
+           SPEC_ADDR (sym->etype) = SPEC_ADDR (csym->etype);
+         }
+       if (IS_SPEC(csym->etype) && !SPEC_ABSA(csym->etype)
+           && IS_SPEC(sym->etype) && SPEC_ABSA(sym->etype))
+         {
+           SPEC_ABSA (csym->etype) = 1;
+           SPEC_ADDR (csym->etype) = SPEC_ADDR (sym->etype);
+         }
+       #endif
+  
         error = 0;        
         if (csym->ival && sym->ival)
           error = 1;
@@ -1012,7 +1029,15 @@ addSymChain (symbol * symHead)
            werror (E_EXTERN_MISMATCH, sym->name);
           else
            werror (E_DUPLICATE, sym->name);
-         printFromToType (csym->type, sym->type);
+         fprintf (stderr, "from type '");
+         printTypeChain (csym->type, stderr);
+         if (IS_SPEC (csym->etype) && SPEC_ABSA (csym->etype))
+           fprintf(stderr, " at 0x%x", SPEC_ADDR (csym->etype));
+         fprintf (stderr, "'\nto type '");
+         printTypeChain (sym->type, stderr);
+         if (IS_SPEC (sym->etype) && SPEC_ABSA (sym->etype))
+           fprintf(stderr, " at 0x%x", SPEC_ADDR (sym->etype));
+         fprintf (stderr, "'\n");
          continue;
        }