Fix error messages which could cause SEGV on Solaris
[fw/sdcc] / src / SDCCmem.c
index 54c8d0122bc92c5261b0e041b4f1458aa6082f0e..dece30c26ef3fe7a78237ed3aaecb0b523673e31 100644 (file)
@@ -351,14 +351,6 @@ allocGlobal (symbol * sym)
       SPEC_SCLS (sym->etype) == S_SBIT)
     {
 
-      /* if both absolute address & initial  */
-      /* value specified then error        */
-      if (IS_ABSOLUTE (sym->etype) && sym->ival)
-       {
-         werror (E_SFR_INIT, sym->name);
-         sym->ival = NULL;
-       }
-
       SPEC_OCLS (sym->etype) =
        (SPEC_SCLS (sym->etype) == S_SFR ? sfr : sfrbit);
 
@@ -571,8 +563,9 @@ deallocParms (value * val)
       if (!lval->sym->isref)
        {
          lval->sym->allocreq = 0;
-         werror (W_NO_REFERENCE, currFunc->name,
-                 "function argument", lval->sym->name);
+           werror (W_NO_REFERENCE, 
+                   currFunc ? currFunc->name : "(unknown)",
+                   "function argument", lval->sym->name);
        }
 
       /* move the rname if any to the name for both val & sym */
@@ -683,15 +676,6 @@ allocLocal (symbol * sym)
   if (SPEC_SCLS (sym->etype) == S_SFR ||
       SPEC_SCLS (sym->etype) == S_SBIT)
     {
-
-      /* if both absolute address & initial  */
-      /* value specified then error        */
-      if (IS_ABSOLUTE (sym->etype) && sym->ival)
-       {
-         werror (E_SFR_INIT, sym->name);
-         sym->ival = NULL;
-       }
-
       SPEC_OCLS (sym->etype) =
        (SPEC_SCLS (sym->etype) == S_SFR ? sfr : sfrbit);
 
@@ -726,11 +710,11 @@ allocLocal (symbol * sym)
      will remove and put into the 'data' segment if required after 
      overlay  analysis has been done */
   if (options.model == MODEL_SMALL) {
-    SPEC_OCLS (sym->etype) = 
-      (options.noOverlay ? port->mem.default_local_map
-       : overlay);
+      SPEC_OCLS (sym->etype) = 
+       (options.noOverlay ? port->mem.default_local_map
+        : overlay);
   } else {
-    SPEC_OCLS (sym->etype) = port->mem.default_local_map;
+      SPEC_OCLS (sym->etype) = port->mem.default_local_map;
   }
   allocIntoSeg (sym);
 }
@@ -758,7 +742,8 @@ deallocLocal (symbol * csym)
        }
       /* if not used give a warning */
       if (!sym->isref && !IS_STATIC (sym->etype))
-       werror (W_NO_REFERENCE, currFunc->name,
+       werror (W_NO_REFERENCE, 
+               currFunc ? currFunc->name : "(unknown)",
                "local variable", sym->name);
       /* now delete it from the symbol table */
       deleteSym (SymbolTab, sym, sym->name);
@@ -977,18 +962,6 @@ redoStackOffsets (void)
       xsPtr += size;
     }
 
-  /* if the debug option is set then output the
-     symbols to the map file */
-  if (options.debug)
-    {
-      for (sym = setFirstItem (istack->syms); sym;
-          sym = setNextItem (istack->syms))
-       cdbSymbol (sym, cdbFile, FALSE, FALSE);
-
-      for (sym = setFirstItem (xstack->syms); sym;
-          sym = setNextItem (xstack->syms))
-       cdbSymbol (sym, cdbFile, FALSE, FALSE);
-    }
 }
 
 /*-----------------------------------------------------------------*/
@@ -1112,9 +1085,12 @@ doOverlays (eBBlock ** ebbs, int count)
 void 
 printAllocInfo (symbol * func, FILE * of)
 {
+  if (!func)
+       return;
+    
   if (!of)
     of = stdout;
-
+    
   /* must be called after register allocation is complete */
   fprintf (of, ";------------------------------------------------------------\n");
   fprintf (of, ";Allocation info for local variables in function '%s'\n", func->name);