aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeongbae Park <seongbae.park@gmail.com>2007-08-16 17:30:20 +0000
committerSeongbae Park <spark@gcc.gnu.org>2007-08-16 17:30:20 +0000
commitd407ad672934d4cdca932d108fddde8f4a75af97 (patch)
treed788fd42d7efa7d166ddd35978c8f79553fe4db1
parentac7d7749c082ec30d145860578ebd905a709ce50 (diff)
downloadgcc-d407ad672934d4cdca932d108fddde8f4a75af97.zip
gcc-d407ad672934d4cdca932d108fddde8f4a75af97.tar.gz
gcc-d407ad672934d4cdca932d108fddde8f4a75af97.tar.bz2
tree-eh.c (lower_try_finally_onedest): Reset the locus of GOTO that's relocated to a different block.
gcc/ChangeLog: 2007-08-16 Seongbae Park <seongbae.park@gmail.com> * tree-eh.c (lower_try_finally_onedest): Reset the locus of GOTO that's relocated to a different block. gcc/testsuite/ChangeLog: 2007-08-16 Seongbae Park <seongbae.park@gmail.com> * g++.dg/gcov/gcov-4.C: New test. * lib/gcov.exp (verify-lines): Add support for checking no-coverage lines. From-SVN: r127562
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/gcov/gcov-4.C41
-rw-r--r--gcc/testsuite/lib/gcov.exp4
-rw-r--r--gcc/tree-eh.c3
5 files changed, 58 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 05c2b29..6f8ed5a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2007-08-16 Seongbae Park <seongbae.park@gmail.com>
+
+ * tree-eh.c (lower_try_finally_onedest): Reset the locus
+ of GOTO that's relocated to a different block.
+
2007-08-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* c-common.c (const_strip_array_types): New.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 387b579..37532f5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2007-08-16 Seongbae Park <seongbae.park@gmail.com>
+
+ * g++.dg/gcov/gcov-4.C: New test.
+ * lib/gcov.exp (verify-lines): Add support for
+ checking no-coverage lines.
+
2007-08-16 Victor Kaplansky <victork@il.ibm.com>
* gcc.dg/vect/vect-vfa-01.c: New.
diff --git a/gcc/testsuite/g++.dg/gcov/gcov-4.C b/gcc/testsuite/g++.dg/gcov/gcov-4.C
new file mode 100644
index 0000000..2f83ff1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gcov/gcov-4.C
@@ -0,0 +1,41 @@
+/* Check that execution counts and branch probabilities for various C
+ constructs are reported correctly by gcov. */
+
+#include <stdio.h>
+
+/* { dg-options "-fprofile-arcs -ftest-coverage -fno-exceptions" } */
+/* { dg-do run { target native } } */
+
+class foo {
+public:
+ foo() { printf("foo()\n"); };
+ ~foo() { printf("~foo()\n"); };
+ void method(void) { printf("method()\n"); };
+};
+
+int func(int i, int j) __attribute__((noinline));
+
+int func(int i, int j){
+ if (j) {
+ printf("unreachable\n");
+ return 3;
+ }
+
+ foo f;
+
+ if (i == 1) {
+ f.method();
+ f.method();
+ } else {
+ f.method();
+ printf("unreachable\n");
+ return 2; /* count(#####) */
+ }
+ f.method();
+ return 0;
+}
+
+int main() {
+ return func(1, 0);
+}
+/* { dg-final { run-gcov gcov-4.C } } */
diff --git a/gcc/testsuite/lib/gcov.exp b/gcc/testsuite/lib/gcov.exp
index 35e86958..1c748478 100644
--- a/gcc/testsuite/lib/gcov.exp
+++ b/gcc/testsuite/lib/gcov.exp
@@ -42,7 +42,9 @@ proc verify-lines { testcase file } {
set failed 0
set fd [open $file r]
while { [gets $fd line] >= 0 } {
- if [regexp "^ *(\[^:]*): *(\[0-9\]+):.*count\\((\[0-9\]+)\\)" \
+ # We want to match both "-" and "#####" as count as well as numbers,
+ # since we want to detect lines that shouldn't be marked as covered.
+ if [regexp "^ *(\[^:]*): *(\[0-9\\-#]+):.*count\\((\[0-9\\-#]+)\\)" \
"$line" all is n shouldbe] {
if { $is == "" } {
fail "$n:no data available for this line"
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 659bbfda..89f863f 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -1020,6 +1020,9 @@ lower_try_finally_onedest (struct leh_state *state, struct leh_tf_state *tf)
}
}
+ /* Reset the locus of the goto since we're moving
+ goto to a different block which might be on a different line. */
+ SET_EXPR_LOCUS (tf->goto_queue[0].cont_stmt, NULL);
append_to_statement_list (tf->goto_queue[0].cont_stmt, tf->top_p);
maybe_record_in_goto_queue (state, tf->goto_queue[0].cont_stmt);
}