* src/SDCCmain.c (setParseWithComma): fixed bug #816685
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 9 Oct 2003 05:29:23 +0000 (05:29 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 9 Oct 2003 05:29:23 +0000 (05:29 +0000)
* 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
src/SDCCmain.c
src/SDCCsymt.c
src/z80/gen.c

index 61accb82a155f20d4ae17d333433297ca9ebf97e..4f23190ee66921d145350805bcbf5a8a06e0e63f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2003-10-09  Erik Petrich <epetrich@ivorytower.norman.ok.us>
+
+       * 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 <bernhard@bernhardheld.de>
 
        Replaced cast (void **) with (void *) to avoid gcc 3 warning:
index ea98540c91ec5e9b1679a82fa83e7c1f1161c4e5..2002576ff8f922d86aa5f5941096b1e10f4e6133 100644 (file)
@@ -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");
index 48a558fd5c28b195e67046100fe3e1b56c413c27..90dc263072d55b324fd8cef78fbc8fb80b51d986 100644 (file)
@@ -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);
index f9a678e917ea0af0ebe5140c5af892288252701e..e159073147471e29ba0ddeb42a3fbd849b89d443 100644 (file)
@@ -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));