fold-const.c (merge_ranges): If range_successor or range_predecessor fail, just return 0.
authorIan Lance Taylor <iant@google.com>
Wed, 6 Jun 2007 13:56:00 +0000 (13:56 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Wed, 6 Jun 2007 13:56:00 +0000 (13:56 +0000)
./: * fold-const.c (merge_ranges): If range_successor or
range_predecessor fail, just return 0.
testsuite/:
* g++.dg/conversion/enum1.C: New test.

From-SVN: r125486

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/conversion/enum1.C [new file with mode: 0644]

index 5fa424d81d5f33f524d4c609c47482ef3c27a173..5e775c31d1608756a3a8eaa0a9472a7de2e008b3 100644 (file)
@@ -1,3 +1,8 @@
+2007-06-06  Ian Lance Taylor  <iant@google.com>
+
+       * fold-const.c (merge_ranges): If range_successor or
+       range_predecessor fail, just return 0.
+
 2007-06-06  Uros Bizjak  <ubizjak@gmail.com>
 
        PR tree-optimization/32216
index af48916601c14b8730b2bcf40a0ef071448a5aed..bc6d6022415e7783e52e281ae2d37548f57db8fe 100644 (file)
@@ -4549,13 +4549,24 @@ merge_ranges (int *pin_p, tree *plow, tree *phigh, int in0_p, tree low0,
        {
          low = range_successor (high1);
          high = high0;
-         in_p = (low != 0);
+         in_p = 1;
+         if (low == 0)
+           {
+             /* We are in the weird situation where high0 > high1 but
+                high1 has no successor.  Punt.  */
+             return 0;
+           }
        }
       else if (! subset || highequal)
        {
          low = low0;
          high = range_predecessor (low1);
-         in_p = (high != 0);
+         in_p = 1;
+         if (high == 0)
+           {
+             /* low0 < low1 but low1 has no predecessor.  Punt.  */
+             return 0;
+           }
        }
       else
        return 0;
@@ -4575,7 +4586,12 @@ merge_ranges (int *pin_p, tree *plow, tree *phigh, int in0_p, tree low0,
        {
          low = range_successor (high0);
          high = high1;
-         in_p = (low != 0);
+         in_p = 1;
+         if (low == 0)
+           {
+             /* high1 > high0 but high0 has no successor.  Punt.  */
+             return 0;
+           }
        }
     }
 
index 766369d57546c3c722fed41d60fd6af4548b717f..3917a8051ebb18efa60b89a42690da93c10e4bec 100644 (file)
@@ -1,3 +1,7 @@
+2007-06-06  Ian Lance Taylor  <iant@google.com>
+
+       * g++.dg/conversion/enum1.C: New test.
+
 2007-06-06  Uros Bizjak  <ubizjak@gmail.com>
 
        PR tree-optimization/32216
diff --git a/gcc/testsuite/g++.dg/conversion/enum1.C b/gcc/testsuite/g++.dg/conversion/enum1.C
new file mode 100644 (file)
index 0000000..6ea8cad
--- /dev/null
@@ -0,0 +1,10 @@
+// { dg-do run }
+// { dg-options "-O2 -finline-functions" }
+
+enum E { V = 1 };
+static const E E_MIN = V;
+static const E E_MAX = V;
+
+bool valid(E v) { return v >= E_MIN && v <= E_MAX; }
+
+int main() { return valid(E(2)); }