]> git.gag.com Git - fw/sdcc/blobdiff - src/SDCCglue.c
undid the hackup of const and volatile, the problem is much bigger
[fw/sdcc] / src / SDCCglue.c
index dcca79fe1c0886dc67acd611ca822e08488ded96..400f36ffd59a6c0411c69564c339158de421f4d3 100644 (file)
@@ -405,10 +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_PTR_CONST (val->type) = port->mem.code_ro;
+                               DCL_TYPE (val->type) = port->mem.code_ro;
                        }
                        else if (SPEC_SCLS (expr->left->etype) == S_XDATA)
                                DCL_TYPE (val->type) = FPOINTER;
@@ -464,7 +464,7 @@ 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;
@@ -810,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 (;;)
     {
@@ -1185,8 +1188,10 @@ emitStaticSeg (memmap * map, FILE * out)
              resolveIvalSym (sym->ival);
              printIval (sym, sym->type, sym->ival, out);
              noAlloc--;
-             // if sym->ival is a string, WE don't need it anymore
-             if (IS_AST_SYM_VALUE(list2expr(sym->ival)) &&
+             /* if sym is a simple string and sym->ival is a string, 
+                WE don't need it anymore */
+             if (IS_ARRAY(sym->type) && IS_CHAR(sym->type->next) &&
+                 IS_AST_SYM_VALUE(list2expr(sym->ival)) &&
                  list2val(sym->ival)->sym->isstrlit) {
                freeStringSymbol(list2val(sym->ival)->sym);
              }