X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCCglue.c;h=48323bd4716632f861188cafc24f970384aa91ae;hb=5f678b2bd01145dff19436e885144411ecadbd99;hp=252e0669fa7862c0323bbcc87346cc8e34538735;hpb=5d849184a955f4ed9c01c1e57a5976f4955e15c8;p=fw%2Fsdcc diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 252e0669..48323bd4 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -70,7 +70,7 @@ DEFSETFUNC (rmTmpFiles) if (name) { unlink (name); - free (name); + Safe_free (name); } return 0; } @@ -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 || @@ -245,25 +257,30 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag) it is a global variable */ if (sym->ival && sym->level == 0) { - if (IS_AGGREGATE (sym->type)) + if (IS_AGGREGATE (sym->type)) { ival = initAggregates (sym, sym->ival, NULL); - else + } else { ival = newNode ('=', newAst_VALUE (symbolVal (sym)), decorateType (resolveSymbols (list2expr (sym->ival)))); + } codeOutFile = statsg->oFile; allocInfo = 0; // set ival's lineno to where the symbol was defined - ival->lineno=sym->lineDef; - + if (ival) ival->lineno=sym->lineDef; eBBlockFromiCode (iCodeFromAst (ival)); allocInfo = 1; - /* if the ival was a symbol, delete it from its segment */ - if ((symIval=AST_SYMBOL(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; } } @@ -372,7 +389,7 @@ initPointer (initList * ilist) return val; } wrong: - werror (E_INIT_WRONG); + werror (W_INIT_WRONG); return NULL; } @@ -866,7 +883,7 @@ printIvalPtr (symbol * sym, sym_link * type, initList * ilist, FILE * oFile) /* check the type */ if (compareType (type, val->type) == 0) - werror (E_INIT_WRONG); + werror (W_INIT_WRONG); /* if val is literal */ if (IS_LITERAL (val->etype)) @@ -1528,6 +1545,33 @@ rm_tmpfiles (void) } #endif +/** Creates a temporary file name a'la tmpnam which avoids the bugs + in cygwin wrt c:\tmp. + Scans, in order: TMP, TEMP, TMPDIR, else uses tmpfile(). +*/ +char * +tempfilename (void) +{ +#if !defined(_MSC_VER) + const char *tmpdir = NULL; + if (getenv ("TMP")) + tmpdir = getenv ("TMP"); + else if (getenv ("TEMP")) + tmpdir = getenv ("TEMP"); + else if (getenv ("TMPDIR")) + tmpdir = getenv ("TMPDIR"); + if (tmpdir) + { + char *name = tempnam (tmpdir, "sdcc"); + if (name) + { + return name; + } + } +#endif + return tmpnam (NULL); +} + /** Creates a temporary file a'la tmpfile which avoids the bugs in cygwin wrt c:\tmp. Scans, in order: TMP, TEMP, TMPDIR, else uses tmpfile(). @@ -1545,7 +1589,7 @@ tempfile (void) tmpdir = getenv ("TMPDIR"); if (tmpdir) { - char *name = tempnam (tmpdir, "sdcc"); + char *name = Safe_strdup( tempnam (tmpdir, "sdcc")); if (name) { FILE *fp = fopen (name, "w+b"); @@ -1561,11 +1605,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; -}