* src/z80/peep.c: fixed bug #2648964: --i-code-in-asm crashes sdcc
[fw/sdcc] / src / z80 / peep.c
index affdf1905d45346794e8435d9a52cde803b0587a..3ae394f0c70f3b8a1bd83fe44313c84f755f6b75 100644 (file)
@@ -80,9 +80,9 @@ isReturned(const char *what)
   do
   {
     l = l->next;
-  } while(l->ic->op != FUNCTION);
+  } while(l->isComment || l->ic->op != FUNCTION);
 
-  sym = OP_SYMBOL(IC_LEFT(_G.head->next->next->ic));
+  sym = OP_SYMBOL(IC_LEFT(l->ic));
 
   if(sym && IS_DECL(sym->type))
     {
@@ -195,9 +195,7 @@ findLabel (const lineNode *pl)
 /* Check if reading arg implies reading what. */
 static bool argCont(const char *arg, const char *what)
 {
-       if(arg[0] == '#')
-               return FALSE;
-       return(strstr(arg, what));;
+  return (arg[0] == '#') ? FALSE : strstr(arg, what) != NULL;
 }
 
 static bool
@@ -262,7 +260,7 @@ z80MightRead(const lineNode *pl, const char *what)
     strncmp(pl->line, "dec\t", 4) == 0 ||
     strncmp(pl->line, "inc\t", 4) == 0 ||
     strncmp(pl->line, "rl\t", 4) == 0 ||
-    strncmp(pl->line, "rr\t", 4) == 0 ||  
+    strncmp(pl->line, "rr\t", 4) == 0 ||
     strncmp(pl->line, "sla\t", 4) == 0 ||
     strncmp(pl->line, "sra\t", 4) == 0 ||
     strncmp(pl->line, "srl\t", 4) == 0)