* src/SDCCicode.c (geniCodeJumpTable): fixed bug #967601
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 8 Jun 2004 04:04:41 +0000 (04:04 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 8 Jun 2004 04:04:41 +0000 (04:04 +0000)
* src/SDCCpeeph.c (labelIsReturnOnly): fixed bug #966505

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3355 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCicode.c
src/SDCCpeeph.c

index 8cbd19d65f2db4b1bcc51af59a7085cc3382971e..36d2c9d3bd71b61fbe5ad22ee6cbe08fafab3fb5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-06-08 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+       * src/SDCCicode.c (geniCodeJumpTable): fixed bug #967601
+       * src/SDCCpeeph.c (labelIsReturnOnly): fixed bug #966505
+
 2004-06-07 Vangelis Rokas <vrokas AT otenet.gr>
 
        Cumulative patch for pic16 port:
index 9b841e5219bc278fc546397106634b626160a5ad..cc530311e7077b22d4cd0bb37156f421fb4a083d 100644 (file)
@@ -3522,6 +3522,23 @@ geniCodeJumpTable (operand * cond, value * caseVals, ast * tree)
 
   falseLabel = newiTempLabel (buffer);
 
+  /* If cond is volatile, it might change after the boundary  */
+  /* conditions are tested to an out of bounds value, causing */
+  /* a jump to a location outside of the jump table. To avoid */
+  /* this possibility, use a non-volatile copy of it instead. */
+  if (IS_OP_VOLATILE (cond))
+    {
+      operand * newcond;
+      iCode * ic;
+      
+      newcond = newiTempOperand (operandType (cond), TRUE);
+      newcond->isvolatile = 0;
+      ic = newiCode ('=', NULL, cond);
+      IC_RESULT (ic) = newcond;
+      ADDTOCHAIN (ic);
+      cond = newcond;
+    }
+
   /* so we can create a jumptable */
   /* first we rule out the boundary conditions */
   /* if only optimization says so */
index a034e34c1365c7b7b2b163a57c97771c5b31c628..670f70792f070fa3214e2a8fa8037de9c61d1f4a 100644 (file)
@@ -193,7 +193,7 @@ FBYNAME (labelIsReturnOnly)
   len = strlen(label);
 
   for(pl = currPl; pl; pl = pl->next) {
-       if (pl->line && !pl->isDebug &&
+       if (pl->line && !pl->isDebug && !pl->isComment &&
          pl->line[strlen(pl->line)-1] == ':') {
                if (strncmp(pl->line, label, len) == 0) break; /* Found Label */
                if (strlen(pl->line) != 7 || !isdigit(*(pl->line)) ||
@@ -206,6 +206,8 @@ FBYNAME (labelIsReturnOnly)
   }
   if (!pl) return FALSE; /* did not find the label */
   pl = pl->next;
+  while (pl && (pl->isDebug || pl->isComment))
+    pl = pl->next;
   if (!pl || !pl->line || pl->isDebug) return FALSE; /* next line not valid */
   p = pl->line;
   for (p = pl->line; *p && isspace(*p); p++)