summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/gcov/gcov-4.C
blob: 2f83ff1becc68a5131423ae7050704faa978dc9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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 } } */