a better fix for bug #456966
[fw/sdcc] / src / SDCCglue.c
index 10843a5e93589797127f8964dc526d00644c1432..55cba41eb5eb2596f940e686898ce201bc5cbe46 100644 (file)
@@ -99,6 +99,11 @@ aopLiteralLong (value * val, int offset, int size)
        }
        fl;
 
+       if (!val) {
+         // assuming we have been warned before
+         val=constVal("0");
+       }
+
        /* if it is a float then it gets tricky */
        /* otherwise it is fairly simple */
        if (!IS_FLOAT (val->type)) {
@@ -181,11 +186,18 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag)
       /* if allocation required check is needed
          then check if the symbol really requires
          allocation only for local variables */
+
       if (arFlag && !IS_AGGREGATE (sym->type) &&
          !(sym->_isparm && !IS_REGPARM (sym->etype)) &&
          !sym->allocreq && sym->level)
        continue;
 
+      /* for bitvar locals and parameters */
+      if (!arFlag && !sym->allocreq && sym->level 
+         && !SPEC_ABSA (sym->etype)) {
+       continue;
+      }
+
       /* if global variable & not static or extern
          and addPublics allowed then add it to the public set */
       if ((sym->level == 0 ||
@@ -256,16 +268,19 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag)
 
          // set ival's lineno to where the symbol was defined
          if (ival) ival->lineno=sym->lineDef;
-
          eBBlockFromiCode (iCodeFromAst (ival));
          allocInfo = 1;
 
-         /* if the ival was a symbol, delete it from its segment */
-         if (IS_AST_SYM_VALUE(sym->ival->init.node)) {
+         /* if the ival is a symbol assigned to an aggregate,
+            (bug #458099 -> #462479)
+            we don't need it anymore, so delete it from its segment */
+         if (IS_AST_SYM_VALUE(sym->ival->init.node) &&
+             IS_AGGREGATE (sym->type) ) {
            symIval=AST_SYMBOL(sym->ival->init.node);
            segment = SPEC_OCLS (symIval->etype);
            deleteSetItem (&segment->syms, symIval);
          }
+
          sym->ival = NULL;
        }
     }
@@ -1563,11 +1578,3 @@ tempfile (void)
   return tmpfile ();
 }
 
-char *
-gc_strdup (const char *s)
-{
-  char *ret;
-  ret = Safe_calloc (1, strlen (s) + 1);
-  strcpy (ret, s);
-  return ret;
-}