]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR gcov-profile/64634 (gcov reports catch(...) as not executed)
authorJakub Jelinek <jakub@redhat.com>
Wed, 3 Jun 2015 21:33:22 +0000 (23:33 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 3 Jun 2015 21:33:22 +0000 (23:33 +0200)
Backported from mainline
2015-02-18  Jakub Jelinek  <jakub@redhat.com>

PR gcov-profile/64634
* tree-eh.c (frob_into_branch_around): Fix up typos
in function comment.
(lower_catch): Put eh_seq resulting from EH lowering of
the cleanup sequence after the cleanup rather than before
it.

* g++.dg/gcov/gcov-15.C: New test.

From-SVN: r224102

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

index da6c3426a6cc436d575ce411cb7a9fbfa5b43c10..5e502416bddd27e6795daf596e001e8d557dc36d 100644 (file)
@@ -1,3 +1,15 @@
+2015-06-03  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2015-02-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR gcov-profile/64634
+       * tree-eh.c (frob_into_branch_around): Fix up typos
+       in function comment.
+       (lower_catch): Put eh_seq resulting from EH lowering of
+       the cleanup sequence after the cleanup rather than before
+       it.
+
 2015-06-03  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
index b5a32359d49eab8d5d61c9ed85c9712a4b16a295..132c0f216a3ac7d43c902431567f6f0dc1bd13c0 100644 (file)
@@ -1,3 +1,11 @@
+2015-06-03  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2015-02-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR gcov-profile/64634
+       * g++.dg/gcov/gcov-15.C: New test.
+
 2015-06-03  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
diff --git a/gcc/testsuite/g++.dg/gcov/gcov-15.C b/gcc/testsuite/g++.dg/gcov/gcov-15.C
new file mode 100644 (file)
index 0000000..fcd16b0
--- /dev/null
@@ -0,0 +1,26 @@
+// PR gcov-profile/64634
+// { dg-options "-fprofile-arcs -ftest-coverage" }
+// { dg-do run { target native } }
+
+void catchEx ()                // count(1)
+{
+  __builtin_exit (0);  // count(1)
+  try
+  {}
+  catch (int)
+  {}
+}
+
+int main ()            // count(1)
+{
+  try
+  {
+    throw 5;           // count(1)
+  }
+  catch (...)          // count(1)
+  {
+    catchEx ();                // count(1)
+  }
+}
+
+// { dg-final { run-gcov gcov-15.C } }
index 902ce452791c601b7448fddc7eaeb755addef490..123ae997179b6ca735f4c3e04351941eb2fbbd56 100644 (file)
@@ -828,10 +828,10 @@ eh_region_may_contain_throw (eh_region r)
 /* We want to transform
        try { body; } catch { stuff; }
    to
-       normal_seqence:
+       normal_sequence:
          body;
          over:
-       eh_seqence:
+       eh_sequence:
          landing_pad:
          stuff;
          goto over;
@@ -1752,6 +1752,12 @@ lower_catch (struct leh_state *state, gimple tp)
   this_state.cur_region = state->cur_region;
   this_state.ehp_region = try_region;
 
+  /* Add eh_seq from lowering EH in the cleanup sequence after the cleanup
+     itself, so that e.g. for coverage purposes the nested cleanups don't
+     appear before the cleanup body.  See PR64634 for details.  */
+  gimple_seq old_eh_seq = eh_seq;
+  eh_seq = NULL;
+
   out_label = NULL;
   cleanup = gimple_try_cleanup (tp);
   for (gsi = gsi_start (cleanup);
@@ -1788,7 +1794,11 @@ lower_catch (struct leh_state *state, gimple tp)
 
   gimple_try_set_cleanup (tp, new_seq);
 
-  return frob_into_branch_around (tp, try_region, out_label);
+  gimple_seq new_eh_seq = eh_seq;
+  eh_seq = old_eh_seq;
+  gimple_seq ret_seq = frob_into_branch_around (tp, try_region, out_label);
+  gimple_seq_add_seq (&eh_seq, new_eh_seq);
+  return ret_seq;
 }
 
 /* A subroutine of lower_eh_constructs_1.  Lower a GIMPLE_TRY with a