re PR c++/71100 (Internal compiler error while calling a pointer to member function...
authorJakub Jelinek <jakub@redhat.com>
Wed, 18 May 2016 21:23:07 +0000 (23:23 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 18 May 2016 21:23:07 +0000 (23:23 +0200)
PR c++/71100
* cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Don't drop
lhs if it has TREE_ADDRESSABLE type.

* g++.dg/opt/pr71100.C: New test.

From-SVN: r236430

gcc/ChangeLog
gcc/cgraph.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr71100.C [new file with mode: 0644]

index 4d261f7872d8613528c1cf88fe4e6f1f2f251d25..3b94d646829e60e73a1ea58d8b84261c8bab61ca 100644 (file)
@@ -1,3 +1,9 @@
+2016-05-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/71100
+       * cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Don't drop
+       lhs if it has TREE_ADDRESSABLE type.
+
 2016-05-18  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/71145
index 6fcdbddb7fc8395094abe9687550135223d0d06c..cf9192f2a1bf85f1c60c3d12d5900226c3207af6 100644 (file)
@@ -1515,7 +1515,8 @@ cgraph_edge::redirect_call_stmt_to_callee (void)
   /* If the call becomes noreturn, remove the LHS if possible.  */
   if (lhs
       && (gimple_call_flags (new_stmt) & ECF_NORETURN)
-      && TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (lhs))) == INTEGER_CST)
+      && TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (lhs))) == INTEGER_CST
+      && !TREE_ADDRESSABLE (TREE_TYPE (lhs)))
     {
       if (TREE_CODE (lhs) == SSA_NAME)
        {
index 66f5cba3c8e80c16abfb87ca9eff1901fb7dd198..6a684fc52d4ae8c01582d54d1d603f847f8537c3 100644 (file)
@@ -1,3 +1,8 @@
+2016-05-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/71100
+       * g++.dg/opt/pr71100.C: New test.
+
 2016-05-18  Martin Jambor  <mjambor@suse.cz>
 
        PR ipa/69708
diff --git a/gcc/testsuite/g++.dg/opt/pr71100.C b/gcc/testsuite/g++.dg/opt/pr71100.C
new file mode 100644 (file)
index 0000000..ff739e2
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/71100
+// { dg-do compile }
+// { dg-options "-O2" }
+
+struct D { ~D (); };
+struct E { D foo () { throw 1; } };
+
+inline void
+bar (D (E::*f) (), E *o)
+{
+  (o->*f) ();
+}
+
+void
+baz (E *o)
+{
+  bar (&E::foo, o);
+}