OSDN Git Service

./:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 5 Jun 2007 13:18:22 +0000 (13:18 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 5 Jun 2007 13:18:22 +0000 (13:18 +0000)
* tree-vrp.c (compare_values_warnv): Check TREE_NO_WARNING on a
PLUS_EXPR or MINUS_EXPR node before setting *strict_overflow_p.
(extract_range_from_assert): Set TREE_NO_WARNING when creating an
expression.
(test_for_singularity): Likewise.
testsuite/:
* gcc.dg/Wstrict-overflow-19.c: New test.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wstrict-overflow-19.c [new file with mode: 0644]
gcc/tree-vrp.c

index 4ea1037..8da0981 100644 (file)
@@ -1,3 +1,11 @@
+2007-06-05  Ian Lance Taylor  <iant@google.com>
+
+       * tree-vrp.c (compare_values_warnv): Check TREE_NO_WARNING on a
+       PLUS_EXPR or MINUS_EXPR node before setting *strict_overflow_p.
+       (extract_range_from_assert): Set TREE_NO_WARNING when creating an
+       expression.
+       (test_for_singularity): Likewise.
+
 2007-06-05  H.J. Lu  <hongjiu.lu@intel.com>
 
        * config/i386/constraints.md ("Y2"): Replaced by ...
index 8ec62e8..9455213 100644 (file)
@@ -1,3 +1,7 @@
+2007-06-05  Ian Lance Taylor  <iant@google.com>
+
+       * gcc.dg/Wstrict-overflow-19.c: New test.
+
 2007-06-05  Razya Ladelsky  <razya@il.ibm.com>
 
        * gcc.dg/matrix/matrix-6.c: Remove conversion.
diff --git a/gcc/testsuite/gcc.dg/Wstrict-overflow-19.c b/gcc/testsuite/gcc.dg/Wstrict-overflow-19.c
new file mode 100644 (file)
index 0000000..daf98b0
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow" } */
+
+/* Don't warn about an overflow when threading jumps.  We used to get
+   a warning from comparing bounds generated by VRP.  */
+
+int
+bar(int a, int b, int n)
+{
+  if (b > a)
+    n = a - b;
+  if (a >= b)
+    n = 1;
+  return n;
+}
index 1867377..7506092 100644 (file)
@@ -837,7 +837,9 @@ compare_values_warnv (tree val1, tree val2, bool *strict_overflow_p)
       if (!TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (val1)))
        return -2;
 
-      if (strict_overflow_p != NULL)
+      if (strict_overflow_p != NULL
+         && (code1 == SSA_NAME || !TREE_NO_WARNING (val1))
+         && (code2 == SSA_NAME || !TREE_NO_WARNING (val2)))
        *strict_overflow_p = true;
 
       if (code1 == SSA_NAME)
@@ -1252,6 +1254,8 @@ extract_range_from_assert (value_range_t *vr_p, tree expr)
            {
              tree one = build_int_cst (type, 1);
              max = fold_build2 (MINUS_EXPR, type, max, one);
+             if (EXPR_P (max))
+               TREE_NO_WARNING (max) = 1;
            }
 
          set_value_range (vr_p, VR_RANGE, min, max, vr_p->equiv);
@@ -1285,6 +1289,8 @@ extract_range_from_assert (value_range_t *vr_p, tree expr)
            {
              tree one = build_int_cst (type, 1);
              min = fold_build2 (PLUS_EXPR, type, min, one);
+             if (EXPR_P (min))
+               TREE_NO_WARNING (min) = 1;
            }
 
          set_value_range (vr_p, VR_RANGE, min, max, vr_p->equiv);
@@ -5646,6 +5652,8 @@ test_for_singularity (enum tree_code cond_code, tree op0,
        {
          tree one = build_int_cst (TREE_TYPE (op0), 1);
          max = fold_build2 (MINUS_EXPR, TREE_TYPE (op0), max, one);
+         if (EXPR_P (max))
+           TREE_NO_WARNING (max) = 1;
        }
     }
   else if (cond_code == GE_EXPR || cond_code == GT_EXPR)
@@ -5659,6 +5667,8 @@ test_for_singularity (enum tree_code cond_code, tree op0,
        {
          tree one = build_int_cst (TREE_TYPE (op0), 1);
          min = fold_build2 (PLUS_EXPR, TREE_TYPE (op0), min, one);
+         if (EXPR_P (min))
+           TREE_NO_WARNING (min) = 1;
        }
     }