Debian Codegraph @

gcc/testsuite/g++.dg/gcov/gcov-4.C

raw
1 /* Check that execution counts and branch probabilities for various C
2 constructs are reported correctly by gcov. */
3
4 #include <stdio.h>
5
6 /* { dg-options "-fprofile-arcs -ftest-coverage -fno-exceptions" } */
7 /* { dg-do run { target native } } */
8
9 class foo {
10 public:
11 foo() { printf("foo()\n"); };
12 ~foo() { printf("~foo()\n"); };
13 void method(void) { printf("method()\n"); };
14 };
15
16 int func(int i, int j) __attribute__((noinline));
17
18 int func(int i, int j){
19 if (j) {
20 printf("unreachable\n");
21 return 3;
22 }
23
24 foo f;
25
26 if (i == 1) {
27 f.method();
28 f.method();
29 } else {
30 f.method();
31 printf("unreachable\n");
32 return 2; /* count(#####) */
33 }
34 f.method();
35 return 0;
36 }
37
38 int main() {
39 return func(1, 0);
40 }
41 /* { dg-final { run-gcov gcov-4.C } } */