* src/SDCCicode.c (geniCodeSwitch, geniCodeJumpTable): fixed
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 17 Mar 2005 06:52:33 +0000 (06:52 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 17 Mar 2005 06:52:33 +0000 (06:52 +0000)
bug #1164313

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

ChangeLog
src/SDCCicode.c

index 827acfade3e7fdad1c5d85625a8064efabe93ad1..46309454293c9f8b456156601ee25cb5b1f6612b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-03-16 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+       * src/SDCCicode.c (geniCodeSwitch, geniCodeJumpTable): fixed
+       bug #1164313
+
 2005-03-16 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
 
        * src/SDCCcse.c (cseBBlock): retain assignment to self when volatile
index 4d0a9f4bf1d4a488b6c1c19f077fe91c19ffca2d..334ff8d83d0430da9b51f67a73da5b9b9f9e9bf0 100644 (file)
@@ -3699,23 +3699,6 @@ geniCodeJumpTable (operand * cond, value * caseVals, ast * tree)
         }
     }
 
-  /* 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;
-    }
-
   /* first we rule out the boundary conditions */
   /* if only optimization says so */
   if (needRangeCheck)
@@ -3785,6 +3768,22 @@ geniCodeSwitch (ast * tree,int lvl)
         }
       goto defaultOrBreak;
     }
+  
+  /* If cond is volatile, it might change while we are trying to */
+  /* find the matching case. To avoid this possibility, make a   */
+  /* non-volatile copy to use 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;
+    }
 
   /* if we can make this a jump table */
   if (geniCodeJumpTable (cond, caseVals, tree))