OSDN Git Service

* jcf-write.c (generate_bytecode_insns) [SWITCH_EXPR]: Handle case
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 20 Dec 2002 19:25:46 +0000 (19:25 +0000)
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 20 Dec 2002 19:25:46 +0000 (19:25 +0000)
where minimum case value is Integer.MIN_VALUE.
Fixes PR java/8955.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@60372 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/java/ChangeLog
gcc/java/jcf-write.c

index 3b6cf6c..7567830 100644 (file)
@@ -1,3 +1,9 @@
+2002-12-20  Tom Tromey  <tromey@redhat.com>
+
+       * jcf-write.c (generate_bytecode_insns) [SWITCH_EXPR]: Handle case
+       where minimum case value is Integer.MIN_VALUE.
+       Fixes PR java/8955.
+
 2002-12-18  Andrew Haley  <aph@redhat.com>
 
        * parse.y (patch_invoke): Force evaluation order when `check' is
index bfb1bd2..866ba7d 100644 (file)
@@ -1746,6 +1746,7 @@ generate_bytecode_insns (exp, target, state)
        else
          {
            HOST_WIDE_INT i;
+           unsigned HOST_WIDE_INT delta;
            /* Copy the chain of relocs into a sorted array. */
            struct jcf_relocation **relocs = (struct jcf_relocation **)
              xmalloc (sw_state.num_cases * sizeof (struct jcf_relocation *));
@@ -1778,8 +1779,11 @@ generate_bytecode_insns (exp, target, state)
                   handled by the parser.  */
              }
 
-           if (2 * sw_state.num_cases
-               >= sw_state.max_case - sw_state.min_case)
+           /* We could have DELTA < 0 if sw_state.min_case is
+              something like Integer.MIN_VALUE.  That is why delta is
+              unsigned.  */
+           delta = sw_state.max_case - sw_state.min_case;
+           if (2 * sw_state.num_cases >= delta)
              { /* Use tableswitch. */
                int index = 0;
                RESERVE (13 + 4 * (sw_state.max_case - sw_state.min_case + 1));