]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[PR c++/83301] cgraph.c segfault
authorThomas Schwinge <thomas@codesourcery.com>
Mon, 11 Dec 2017 09:49:25 +0000 (10:49 +0100)
committerThomas Schwinge <tschwinge@gcc.gnu.org>
Mon, 11 Dec 2017 09:49:25 +0000 (10:49 +0100)
Backport trunk r243377:

gcc/
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.

gcc/testsuite/
2016-12-07  Jakub Jelinek  <jakub@redhat.com>

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

From-SVN: r255538

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

index e586870d1281586cdc6edf3b3c3b2acc8bba78bd..35a70d4fbcf5173c014f5be5f67b88def5ad9c8c 100644 (file)
@@ -1,3 +1,15 @@
+2017-12-11  Thomas Schwinge  <thomas@codesourcery.com>
+
+       PR c++/83301
+
+       Backport trunk r243377:
+       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.
+
 2017-12-04  Sebastian Peryt  <sebastian.peryt@intel.com>
        H.J. Lu  <hongjiu.lu@intel.com>
 
index 6ff8f26ef3917e52b785e2ae00d2e23808512324..0c9d9696c6310e9137e0d73af6b90273050d2096 100644 (file)
@@ -1259,7 +1259,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;
@@ -1529,6 +1528,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_flags (new_stmt) & ECF_NORETURN)
       && (VOID_TYPE_P (TREE_TYPE (gimple_call_fntype (new_stmt)))
index 6a1b459f2b5a9451a0cf18c380d0c04f196ec695..0fae4dce0d1f106a5c67f20d1bf94bc3c3f033d3 100644 (file)
@@ -1,3 +1,13 @@
+2017-12-11  Thomas Schwinge  <thomas@codesourcery.com>
+
+       PR c++/83301
+
+       Backport trunk r243377:
+       2016-12-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/78692
+       * g++.dg/torture/pr78692.C: New test.
+
 2017-12-04  Sebastian Peryt  <sebastian.peryt@intel.com>
        H.J. Lu  <hongjiu.lu@intel.com>
 
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);
+}
+}