* src/hc08/ralloc.c (rematStr): fixed bug #879282
[fw/sdcc] / src / SDCCast.c
index c1ed4b049dfad603e6f80d14a4a64c518d0c6539..56d377602d3544ac124199651ae5eea03b7aca42 100644 (file)
@@ -1782,7 +1782,7 @@ isConformingBody (ast * pbody, symbol * sym, ast * body)
 
       if (astHasVolatile (pbody->left))
        return FALSE;
-      
+
       if (astHasDeref(pbody->right)) return FALSE;
 
       return isConformingBody (pbody->left, sym, body) &&
@@ -3233,6 +3233,23 @@ decorateType (ast * tree)
       /* make sure the type is complete and sane */
       checkTypeSanity(LETYPE(tree), "(cast)");
 
+      /* If code memory is read only, then pointers to code memory */
+      /* implicitly point to constants -- make this explicit       */
+      {
+       sym_link *t = LTYPE(tree);
+       while (t && t->next)
+         {
+           if (IS_CODEPTR(t) && port->mem.code_ro)
+             {
+               if (IS_SPEC(t->next))
+                 SPEC_CONST (t->next) = 1;
+               else
+                 DCL_PTR_CONST (t->next) = 1;
+             }
+           t = t->next;
+          }
+      }
+
 #if 0
       /* if the right is a literal replace the tree */
       if (IS_LITERAL (RETYPE (tree))) {
@@ -3488,6 +3505,8 @@ decorateType (ast * tree)
            }
          if (tree->opval.op == '>')
            {
+             /* if the parent is an ifx, then we could do */
+             /* return tree->left; */
              tree->opval.op = '?';
              tree->right = newNode (':',
                                     newAst_VALUE (constVal ("1")),
@@ -5564,7 +5583,7 @@ void ast_print (ast * tree, FILE *outfile, int indent)
                ast_print(tree->left,outfile,indent+2);
                ast_print(tree->right,outfile,indent+2);
                return ;
-               
+
                /*------------------------------------------------------------------*/
                /*----------------------------*/
                /*    assignment operators    */