1/* Check that execution counts for template functions
2   are reported correctly by gcov. */
3
4#include <stdio.h>
5#include <stdlib.h>
6
7/* { dg-options "-fprofile-arcs -ftest-coverage -fno-inline" } */
8/* { dg-do run { target native } } */
9
10class A {
11  int count;
12 public:
13  A(int c) { count = c; }
14  void func(void) { printf("func\n"); }
15  bool done(void) {
16    return (count == 0) ? true : (count-- != 0);
17  }
18  void run(void) { abort(); }
19};
20
21//typedef A T;
22template<class T>
23void WithoutBrace(T *a) {
24  while (!a->done())
25    a->run();           /* count(#####) */
26}                       /* count(1) */
27
28template<class T>
29void WithBrace(T *a)
30{
31  while (!a->done())
32    {
33      a->run();         /* count(#####) */
34    }
35}                       /* count(1) */
36
37A *func(A *a)
38{
39  WithoutBrace(a);
40  WithBrace(a);
41  return a;
42}
43
44int main() {
45  A a(0);
46  func(&a);
47  return 0;
48}
49
50/* { dg-final { run-gcov gcov-5.C } } */
51