undid the hackup of const and volatile, the problem is much bigger
[fw/sdcc] / src / SDCCglue.c
index e72964cd4dcf5e01550ad3984f49ed002dc81e93..400f36ffd59a6c0411c69564c339158de421f4d3 100644 (file)
@@ -405,9 +405,10 @@ initPointer (initList * ilist, sym_link *toType)
                /* address of symbol */
                if (IS_AST_SYM_VALUE (expr->left)) {
                        val = copyValue (AST_VALUE (expr->left));
-                       val->type = newLink ();
+                       val->type = newLink (DECLARATOR);
                        if (SPEC_SCLS (expr->left->etype) == S_CODE) {
                                DCL_TYPE (val->type) = CPOINTER;
+                               DCL_TYPE (val->type) = port->mem.code_ro;
                        }
                        else if (SPEC_SCLS (expr->left->etype) == S_XDATA)
                                DCL_TYPE (val->type) = FPOINTER;
@@ -463,9 +464,10 @@ initPointer (initList * ilist, sym_link *toType)
            IS_ARRAY(expr->right->ftype)) {
 
                val = copyValue (AST_VALUE (expr->right));
-               val->type = newLink ();
+               val->type = newLink (DECLARATOR);
                if (SPEC_SCLS (expr->right->etype) == S_CODE) {
                        DCL_TYPE (val->type) = CPOINTER;
+                       DCL_PTR_CONST (val->type) = port->mem.code_ro;
                }
                else if (SPEC_SCLS (expr->right->etype) == S_XDATA)
                        DCL_TYPE (val->type) = FPOINTER;
@@ -808,8 +810,11 @@ printIvalArray (symbol * sym, sym_link * type, initList * ilist,
 
   iloop = ilist->init.deep;
   lcnt = DCL_ELEM (type);
-  for (last_type = type->next; last_type && DCL_ELEM (last_type); last_type = last_type->next)
+  for (last_type = type->next; 
+       last_type && IS_DECL(last_type) && DCL_ELEM (last_type); 
+       last_type = last_type->next) {
     lcnt *= DCL_ELEM (last_type);
+  }
 
   for (;;)
     {