summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/torture/pr34241.C18
-rw-r--r--gcc/tree-ssa-forwprop.c9
4 files changed, 35 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index da216cede43..f7cf3afbdf6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2007-11-27 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/34241
+ * tree-ssa-forwprop.c (forward_propagate_addr_expr): Make sure
+ to only delete real conversion chains.
+
2007-11-27 Andreas Krebbel <krebbel1@de.ibm.com>
* config/s390/s390.opt (m31, m64, mesa, mzarch, msoft-float,
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a3c26bfce0c..4e14852e88b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2007-11-27 Richard Guenther <rguenther@suse.de>
+ PR tree-optimization/34241
+ * g++.dg/torture/pr34241.C: New testcase.
+
+2007-11-27 Richard Guenther <rguenther@suse.de>
+
* gcc.dg/builtins-error.c: New testcase.
2007-11-27 Jakub Jelinek <jakub@redhat.com>
diff --git a/gcc/testsuite/g++.dg/torture/pr34241.C b/gcc/testsuite/g++.dg/torture/pr34241.C
new file mode 100644
index 00000000000..70f186c5b9f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr34241.C
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+inline void *operator new (__SIZE_TYPE__, void *__p) throw ()
+{
+ return __p;
+}
+struct A
+{
+ A(int, double);
+ inline explicit A (int pattern, bool cs)
+ {
+ new (this) A (pattern, double(cs));
+ }
+};
+A test ()
+{
+ const A a (42, true);
+}
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index 3e30454ab9f..f368c3321c4 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -685,6 +685,7 @@ forward_propagate_addr_expr (tree name, tree rhs)
FOR_EACH_IMM_USE_STMT (use_stmt, iter, name)
{
bool result;
+ tree use_rhs;
/* If the use is not in a simple assignment statement, then
there is nothing we can do. */
@@ -712,11 +713,13 @@ forward_propagate_addr_expr (tree name, tree rhs)
pop_stmt_changes (&use_stmt);
/* Remove intermediate now unused copy and conversion chains. */
+ use_rhs = GIMPLE_STMT_OPERAND (use_stmt, 1);
if (result
&& TREE_CODE (GIMPLE_STMT_OPERAND (use_stmt, 0)) == SSA_NAME
- && (TREE_CODE (GIMPLE_STMT_OPERAND (use_stmt, 1)) == SSA_NAME
- || TREE_CODE (GIMPLE_STMT_OPERAND (use_stmt, 1)) == NOP_EXPR
- || TREE_CODE (GIMPLE_STMT_OPERAND (use_stmt, 1)) == CONVERT_EXPR))
+ && (TREE_CODE (use_rhs) == SSA_NAME
+ || ((TREE_CODE (use_rhs) == NOP_EXPR
+ || TREE_CODE (use_rhs) == CONVERT_EXPR)
+ && TREE_CODE (TREE_OPERAND (use_rhs, 0)) == SSA_NAME)))
{
block_stmt_iterator bsi = bsi_for_stmt (use_stmt);
release_defs (use_stmt);
OpenPOWER on IntegriCloud