From 3633df5a3dba55008be0049598e0377dfa3809ac Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Sun, 6 Apr 2008 21:20:49 +0000 Subject: [PATCH] re PR middle-end/35400 (-Wtype-limits -O2 causes ICE tree check: expected ssa_name, have addr_expr in get_value_range, at tree-vrp.c:469) 2008-04-06 Richard Guenther PR tree-optimization/35400 * tree-vrp.c (vrp_evaluate_conditional): Only query value-range information from SSA_NAMEs. * gcc.dg/torture/pr35400.c: New testcase. * g++.dg/torture/pr35400.C: Likewise. From-SVN: r133967 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/torture/pr35400.C | 13 +++++++++++++ gcc/testsuite/gcc.dg/torture/pr35400.c | 22 ++++++++++++++++++++++ gcc/tree-vrp.c | 3 ++- 5 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr35400.C create mode 100644 gcc/testsuite/gcc.dg/torture/pr35400.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index da2f5a7cdf8..921982ecbb4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-04-06 Richard Guenther + + PR tree-optimization/35400 + * tree-vrp.c (vrp_evaluate_conditional): Only query value-range + information from SSA_NAMEs. + 2008-04-06 Anatoly Sokolov * config/avr/avr.h (avr_mega_p): Remove declaration. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b5b21556f04..beac0eb46d6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-04-06 Richard Guenther + + PR tree-optimization/35400 + * gcc.dg/torture/pr35400.c: New testcase. + * g++.dg/torture/pr35400.C: Likewise. + 2008-04-06 Paul Thomas PR fortran/35780 diff --git a/gcc/testsuite/g++.dg/torture/pr35400.C b/gcc/testsuite/g++.dg/torture/pr35400.C new file mode 100644 index 00000000000..021135df813 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr35400.C @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-Wtype-limits" } */ + +struct A +{ + A(); + ~A(); +}; + +void foo() +{ + A x[1]; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr35400.c b/gcc/testsuite/gcc.dg/torture/pr35400.c new file mode 100644 index 00000000000..285dc72e3a3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr35400.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-Wtype-limits" } */ + +struct A +{ + struct A *p; +}; + +int foo(const struct A *q) +{ + return q->p == q; +} + +void bar(int); + +void baz() +{ + struct A a; + + while (foo(&a)) + bar(foo(&a)); +} diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 9741262dba2..273b5fdfdc0 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -5385,7 +5385,8 @@ vrp_evaluate_conditional (tree cond, tree stmt) if (warn_type_limits && ret - && TREE_CODE_CLASS (TREE_CODE (cond)) == tcc_comparison) + && TREE_CODE_CLASS (TREE_CODE (cond)) == tcc_comparison + && TREE_CODE (TREE_OPERAND (cond, 0)) == SSA_NAME) { /* If the comparison is being folded and the operand on the LHS is being compared against a constant value that is outside of -- 2.30.2