From 99552e406c4175a2d700149758ba8c6c70d400f2 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Fri, 16 Nov 2007 13:14:03 +0000 Subject: [PATCH] re PR tree-optimization/34113 (ICE in get_addr_dereference_operands, at tree-ssa-operands.c:1746) 2007-11-16 Richard Guenther PR tree-optimization/34113 * tree-ssa-forwprop.c (tree_ssa_forward_propagate_single_use_vars): Use correct conversion direction for checking type compatibility. * gcc.c-torture/compile/pr34113.c: New testcase. From-SVN: r130223 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/compile/pr34113.c | 11 +++++++++++ gcc/tree-ssa-forwprop.c | 4 ++-- 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr34113.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 80dac9c5910..2dc45533068 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2007-11-16 Richard Guenther + + PR tree-optimization/34113 + * tree-ssa-forwprop.c (tree_ssa_forward_propagate_single_use_vars): + Use correct conversion direction for checking type compatibility. + 2007-11-16 Richard Guenther PR tree-optimization/34099 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9c84667f81f..46fd19a8110 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-11-16 Richard Guenther + + PR tree-optimization/34113 + * gcc.c-torture/compile/pr34113.c: New testcase. + 2007-11-16 Richard Guenther PR tree-optimization/34099 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr34113.c b/gcc/testsuite/gcc.c-torture/compile/pr34113.c new file mode 100644 index 00000000000..7694b82600c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr34113.c @@ -0,0 +1,11 @@ +struct sockaddr_in { int sin_addr; }; +static void ConvertAddr (struct sockaddr_in *saddr, void **addr) +{ + *addr = (void *) &saddr->sin_addr; +} +unsigned char EnableLocalHost (struct sockaddr_in *ifa_addr) +{ + unsigned char * addr; + ConvertAddr(ifa_addr, (void **)&addr); + return addr[0]; +} diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index bacd34e7f4d..661d3d2a240 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -959,8 +959,8 @@ tree_ssa_forward_propagate_single_use_vars (void) || TREE_CODE (rhs) == CONVERT_EXPR) && TREE_CODE (TREE_OPERAND (rhs, 0)) == ADDR_EXPR && POINTER_TYPE_P (TREE_TYPE (rhs)) - && useless_type_conversion_p (TREE_TYPE (TREE_TYPE (rhs)), - TREE_TYPE (TREE_TYPE (TREE_OPERAND (rhs, 0)))))) + && useless_type_conversion_p (TREE_TYPE (TREE_TYPE (TREE_OPERAND (rhs, 0))), + TREE_TYPE (TREE_TYPE (rhs))))) { if (forward_propagate_addr_expr (lhs, rhs)) {