From 341294d1d8f1bcd8e7ee542194bfa29b9cc1986e Mon Sep 17 00:00:00 2001 From: epetrich Date: Thu, 9 Oct 2003 05:29:23 +0000 Subject: [PATCH] * src/SDCCmain.c (setParseWithComma): fixed bug #816685 * src/z80/gen.c: fixed part of bug #817589 * src/SDCCsymt.c (checkFunction): fixed bug #817895 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2931 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 6 ++++++ src/SDCCmain.c | 20 +++++++++++++++++--- src/SDCCsymt.c | 14 +++++++++++++- src/z80/gen.c | 46 +++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 79 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 61accb82..4f23190e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-10-09 Erik Petrich + + * src/SDCCmain.c (setParseWithComma): fixed bug #816685 + * src/z80/gen.c: fixed part of bug #817589 + * src/SDCCsymt.c (checkFunction): fixed bug #817895 + 2003-10-08 Bernhard Held Replaced cast (void **) with (void *) to avoid gcc 3 warning: diff --git a/src/SDCCmain.c b/src/SDCCmain.c index ea98540c..2002576f 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -304,6 +304,7 @@ static PORT *_ports[] = #if !OPT_DISABLE_DS400 &ds400_port, #endif + &hc08_port, }; #define NUM_PORTS (sizeof(_ports)/sizeof(_ports[0])) @@ -485,10 +486,16 @@ void setParseWithComma (set **dest, char *src) { char *p; + int length; /* skip the initial white spaces */ while (isspace(*src)) src++; + + /* skip the trailing white spaces */ + length = strlen(src); + while (length && isspace(src[length-1])) + src[--length] = '\0'; for (p = strtok(src, ","); p != NULL; p = strtok(NULL, ",")) addSet(dest, Safe_strdup(p)); @@ -1381,7 +1388,7 @@ linkEdit (char **envp) /* standard library path */ if (!options.nostdlib) { - if (!(TARGET_IS_Z80 || TARGET_IS_GBZ80)) /*Not for the z80, gbz80*/ + if (!(TARGET_IS_Z80 || TARGET_IS_GBZ80 || TARGET_IS_HC08)) /*Not for the z80, gbz80*/ { switch (options.model) { @@ -1420,7 +1427,9 @@ linkEdit (char **envp) } else /*for the z80, gbz80*/ { - if (TARGET_IS_Z80) + if (TARGET_IS_HC08) + c = "hc08"; + else if (TARGET_IS_Z80) c = "z80"; else c = "gbz80"; @@ -1459,13 +1468,18 @@ linkEdit (char **envp) } #endif #endif - if (!(TARGET_IS_Z80 || TARGET_IS_GBZ80)) /*Not for the z80, gbz80*/ + if (!(TARGET_IS_Z80 || TARGET_IS_GBZ80 + || TARGET_IS_HC08)) /*Not for the z80, gbz80*/ { /*Why the z80 port is not using the standard libraries?*/ fprintf (lnkfile, "-l %s\n", STD_LIB); fprintf (lnkfile, "-l %s\n", STD_INT_LIB); fprintf (lnkfile, "-l %s\n", STD_LONG_LIB); fprintf (lnkfile, "-l %s\n", STD_FP_LIB); } + else if (TARGET_IS_HC08) + { + fprintf (lnkfile, "-l hc08\n"); + } else if (TARGET_IS_Z80) { fprintf (lnkfile, "-l z80\n"); diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 48a558fd..90dc2630 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -1028,7 +1028,7 @@ funcInChain (sym_link * lnk) } /*------------------------------------------------------------------*/ -/* structElemType - returns the type info of a sturct member */ +/* structElemType - returns the type info of a struct member */ /*------------------------------------------------------------------*/ sym_link * structElemType (sym_link * stype, value * id) @@ -1776,6 +1776,7 @@ checkFunction (symbol * sym, symbol *csym) werror(E_PARAM_NAME_OMITTED, sym->name, argCnt); } } + argCnt--; if (!csym && !(csym = findSym (SymbolTab, sym, sym->name))) return 1; /* not defined nothing more to check */ @@ -1809,6 +1810,17 @@ checkFunction (symbol * sym, symbol *csym) { werror (E_PREV_DEF_CONFLICT, csym->name, "_naked"); } + + /* Really, reentrant should match regardless of argCnt, but */ + /* this breaks some existing code (the fp lib functions). If */ + /* the first argument is always passed the same way, this */ + /* lax checking is ok (but may not be true for in future ports) */ + if (IFFUNC_ISREENT (csym->type) != IFFUNC_ISREENT (sym->type) + && argCnt>1) + { + //printf("argCnt = %d\n",argCnt); + werror (E_PREV_DEF_CONFLICT, csym->name, "reentrant"); + } /* compare expected args with actual args */ exargs = FUNC_ARGS(csym->type); diff --git a/src/z80/gen.c b/src/z80/gen.c index f9a678e9..e1590731 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -221,7 +221,7 @@ static struct bool in_home; const char *lastFunctionName; iCode *current_iCode; - + set *sendSet; struct @@ -235,6 +235,7 @@ static struct lineNode *head; lineNode *current; int isInline; + int isDebug; allocTrace trace; } lines; @@ -409,6 +410,7 @@ _vemit2 (const char *szFormat, va_list ap) (_G.lines.head = _newLineNode (buffer))); _G.lines.current->isInline = _G.lines.isInline; + _G.lines.current->isDebug = _G.lines.isDebug; _G.lines.current->ic = _G.current_iCode; } @@ -3143,7 +3145,22 @@ genEndFunction (iCode * ic) } - /* Both baned and non-banked just ret */ + if (options.debug && currFunc) + { + _G.lines.isDebug = 1; + sprintf (buffer, "C$%s$%d$%d$%d", + FileBaseName (ic->filename), currFunc->lastLine, + ic->level, ic->block); + emit2 ("!labeldef", buffer); + if (IS_STATIC (currFunc->etype)) + sprintf (buffer, "XF%s$%s$0$0", moduleName, currFunc->name); + else + sprintf (buffer, "XG$%s$0$0", currFunc->name); + emit2 ("!labeldef", buffer); + _G.lines.isDebug = 0; + } + + /* Both banked and non-banked just ret */ emit2 ("ret"); sprintf (buffer, "%s_end", sym->rname); @@ -7671,13 +7688,36 @@ genZ80Code (iCode * lic) } _G.lines.head = _G.lines.current = NULL; + + /* if debug information required */ + if (options.debug && currFunc) + { + debugFile->writeFunction(currFunc); + _G.lines.isDebug = 1; + if (IS_STATIC (currFunc->etype)) + sprintf (buffer, "F%s$%s$0$0", moduleName, currFunc->name); + else + sprintf (buffer, "G$%s$0$0", currFunc->name); + emit2 ("!labeldef", buffer); + _G.lines.isDebug = 0; + } for (ic = lic; ic; ic = ic->next) { _G.current_iCode = ic; - if (cln != ic->lineno) + if (ic->lineno && cln != ic->lineno) { + if (options.debug) + { + _G.lines.isDebug = 1; + sprintf (buffer, "C$%s$%d$%d$%d", + FileBaseName (ic->filename), ic->lineno, + ic->level, ic->block); + emit2 ("%s !equ .", buffer); + emit2 ("!global", buffer); + _G.lines.isDebug = 0; + } if (!options.noCcodeInAsm) { emit2 (";%s:%d: %s", ic->filename, ic->lineno, printCLine(ic->filename, ic->lineno)); -- 2.30.2