From 3eb532d289f6165037652e1faedb98a02730dbbf Mon Sep 17 00:00:00 2001 From: epetrich Date: Thu, 17 Mar 2005 06:52:33 +0000 Subject: [PATCH] * src/SDCCicode.c (geniCodeSwitch, geniCodeJumpTable): fixed bug #1164313 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3699 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 5 +++++ src/SDCCicode.c | 33 ++++++++++++++++----------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 827acfad..46309454 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-03-16 Erik Petrich + + * src/SDCCicode.c (geniCodeSwitch, geniCodeJumpTable): fixed + bug #1164313 + 2005-03-16 Erik Petrich * src/SDCCcse.c (cseBBlock): retain assignment to self when volatile diff --git a/src/SDCCicode.c b/src/SDCCicode.c index 4d0a9f4b..334ff8d8 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -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)) -- 2.30.2