re PR tree-optimization/78692 (ICE (segfault))
authorJakub Jelinek <jakub@redhat.com>
Wed, 7 Dec 2016 19:10:50 +0000 (20:10 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 7 Dec 2016 19:10:50 +0000 (20:10 +0100)
PR c++/78692
* cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Set lhs
var to lhs of new_stmt right before noreturn handling rather than to
lhs of e->call_stmt early.

* g++.dg/torture/pr78692.C: New test.

From-SVN: r243377

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

index c4055dc1501ede01915ee760e6199923f91db364..b14b7900598c897fb58daedff8a02c6e6426129b 100644 (file)
@@ -1,3 +1,10 @@
+2016-12-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/78692
+       * cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Set lhs
+       var to lhs of new_stmt right before noreturn handling rather than to
+       lhs of e->call_stmt early.
+
 2016-12-07  David Malcolm  <dmalcolm@redhat.com>
 
        * read-md.c (rtx_reader::require_char): New method.
index 867e371a3f9a6710084cb41aa9ec20a871e77505..fd2465e81a631e30437a5c822b77cd9d80ec69e0 100644 (file)
@@ -1271,7 +1271,6 @@ cgraph_edge::redirect_call_stmt_to_callee (void)
   cgraph_edge *e = this;
 
   tree decl = gimple_call_fndecl (e->call_stmt);
-  tree lhs = gimple_call_lhs (e->call_stmt);
   gcall *new_stmt;
   gimple_stmt_iterator gsi;
   bool skip_bounds = false;
@@ -1526,6 +1525,7 @@ cgraph_edge::redirect_call_stmt_to_callee (void)
     gimple_call_set_fntype (new_stmt, TREE_TYPE (e->callee->decl));
 
   /* If the call becomes noreturn, remove the LHS if possible.  */
+  tree lhs = gimple_call_lhs (new_stmt);
   if (lhs
       && gimple_call_noreturn_p (new_stmt)
       && (VOID_TYPE_P (TREE_TYPE (gimple_call_fntype (new_stmt)))
index 71bf5066269eef6449d5100a218b2e375496200a..2706d0e51b9be290ce4ec24797dcc062a500261d 100644 (file)
@@ -1,3 +1,8 @@
+2016-12-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/78692
+       * g++.dg/torture/pr78692.C: New test.
+
 2016-12-07  Thomas Preud'homme  <thomas.preudhomme@arm.com>
 
        PR rtl-optimization/78617
diff --git a/gcc/testsuite/g++.dg/torture/pr78692.C b/gcc/testsuite/g++.dg/torture/pr78692.C
new file mode 100644 (file)
index 0000000..57a0d2f
--- /dev/null
@@ -0,0 +1,26 @@
+// PR c++/78692
+
+int a;
+void *b;
+extern "C" {
+struct C {
+  virtual int d ();
+};
+struct E {
+  virtual int operator () (int, const void *, int) = 0;
+};
+class F {
+  int g ();
+  int h;
+  E &i;
+};
+struct : C, E {
+  int operator () (int, const void *, int) { throw int(); }
+} j;
+
+int
+F::g ()
+{
+  a = i (h, b, 0);
+}
+}