From 39f9719e9a6a8f061c8654f4e54d804f61a6f982 Mon Sep 17 00:00:00 2001
From: Jan Hubicka <jh@suse.cz>
Date: Tue, 5 Feb 2013 10:11:53 +0100
Subject: [PATCH] PR tree-optimization/r55789

	* cgraphclones.c (cgraph_remove_node_and_inline_clones): Remove
	the dead call anyway.

	* g++.dg/torture/pr55789.C: New testcase.

From-SVN: r195750
---
 gcc/ChangeLog                          |  6 ++++++
 gcc/cgraphclones.c                     |  5 ++++-
 gcc/testsuite/ChangeLog                |  5 +++++
 gcc/testsuite/g++.dg/torture/pr55789.C | 30 ++++++++++++++++++++++++++
 4 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/torture/pr55789.C

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5af0cea01af0..59eaf4862563 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2013-02-05  Jan Hubicka  <jh@suse.cz>
+
+	PR tree-optimization/r55789
+	* cgraphclones.c (cgraph_remove_node_and_inline_clones): Remove
+	the dead call anyway.
+
 2013-02-05  Eric Botcazou  <ebotcazou@adacore.com>
 
 	PR sanitizer/55374
diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index 30d02d11dd92..3a2e3d679e21 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -570,7 +570,10 @@ cgraph_remove_node_and_inline_clones (struct cgraph_node *node, struct cgraph_no
   bool found = false;
 
   if (node == forbidden_node)
-    return true;
+    {
+      cgraph_remove_edge (node->callers);
+      return true;
+    }
   for (e = node->callees; e; e = next)
     {
       next = e->next_callee;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ab73fbf6b08d..58f1643314b1 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2013-02-05  Jan Hubicka  <jh@suse.cz>
+
+	PR tree-optimization/r55789
+	* g++.dg/torture/pr55789.C: New testcase.
+
 2013-02-05  Jakub Jelinek  <jakub@redhat.com>
 
 	PR middle-end/56167
diff --git a/gcc/testsuite/g++.dg/torture/pr55789.C b/gcc/testsuite/g++.dg/torture/pr55789.C
new file mode 100644
index 000000000000..a5a31a4f517c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr55789.C
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-fno-guess-branch-probability  -fno-tree-forwprop --param max-early-inliner-iterations=10 --param=early-inlining-insns=176" } */
+
+template < typename T > struct intrusive_ptr
+{
+  ~intrusive_ptr ()
+  {
+    delete px;
+  }
+  T *px;
+};
+
+struct section_info
+{
+  intrusive_ptr < section_info > parent;
+};
+
+struct file_info
+{
+  intrusive_ptr < file_info > parent;
+  intrusive_ptr < section_info > switched_section;
+};
+
+
+void
+start_file (void)
+{
+  intrusive_ptr < file_info > parent;
+}
+
-- 
GitLab