]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR middle-end/57499 (ICE when noreturn destructor returns after throw...
authorJakub Jelinek <jakub@redhat.com>
Thu, 6 Mar 2014 07:54:28 +0000 (08:54 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 6 Mar 2014 07:54:28 +0000 (08:54 +0100)
Backport from mainline
2014-02-05  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/57499
* tree-eh.c (cleanup_empty_eh): Bail out on totally empty
bb with no successors.

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

From-SVN: r208363

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr57499.C [new file with mode: 0644]
gcc/tree-eh.c

index f0b9daab896edd80863e6c09b2928847ee70146a..347cf1f8537d8e21382dcbc829efb9ef453af61b 100644 (file)
@@ -1,3 +1,12 @@
+2014-03-06  Jakub Jelinek  <jakub@redhat.com>
+
+       Backport from mainline
+       2014-02-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/57499
+       * tree-eh.c (cleanup_empty_eh): Bail out on totally empty
+       bb with no successors.
+
 2014-03-04  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/60382
index a86397f2e1a77b21e82c1851f8b10f2e6717c2a0..85648af403a2086944d1ad9b4c47d28df9b9b05a 100644 (file)
@@ -1,6 +1,11 @@
 2014-03-06  Jakub Jelinek  <jakub@redhat.com>
 
        Backport from mainline
+       2014-02-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/57499
+       * g++.dg/torture/pr57499.C: New test.
+
        2014-03-03  Jakub Jelinek  <jakub@redhat.com>
 
        PR preprocessor/60400
diff --git a/gcc/testsuite/g++.dg/torture/pr57499.C b/gcc/testsuite/g++.dg/torture/pr57499.C
new file mode 100644 (file)
index 0000000..fd985a1
--- /dev/null
@@ -0,0 +1,14 @@
+// PR middle-end/57499
+// { dg-do compile }
+
+struct S
+{
+  ~S () __attribute__ ((noreturn)) {} // { dg-warning "function does return" }
+};
+
+void
+foo ()
+{
+  S s;
+  throw 1;
+}
index 87fea6d07cfbd39c0a8ebc6dbefeb57a2dfeeb38..902ce452791c601b7448fddc7eaeb755addef490 100644 (file)
@@ -4184,8 +4184,11 @@ cleanup_empty_eh (eh_landing_pad lp)
   /* If the block is totally empty, look for more unsplitting cases.  */
   if (gsi_end_p (gsi))
     {
-      /* For the degenerate case of an infinite loop bail out.  */
-      if (infinite_empty_loop_p (e_out))
+      /* For the degenerate case of an infinite loop bail out.
+        If bb has no successors and is totally empty, which can happen e.g.
+        because of incorrect noreturn attribute, bail out too.  */
+      if (e_out == NULL
+         || infinite_empty_loop_p (e_out))
        return ret;
 
       return ret | cleanup_empty_eh_unsplit (bb, e_out, lp);