2016-09-26 François Dumont <fdumont@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / g++.dg / gcov / gcov-5.C
blob9ada41802caa18381b7c90cb384b2d3cfcd3f5bb
1 /* Check that execution counts for template functions
2    are reported correctly by gcov. */
4 #include <stdio.h>
5 #include <stdlib.h>
7 /* { dg-options "-fprofile-arcs -ftest-coverage -fno-inline" } */
8 /* { dg-do run { target native } } */
10 class 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(); }
21 //typedef A T;
22 template<class T>
23 void WithoutBrace(T *a) {
24   while (!a->done())   
25     a->run();           /* count(#####) */
26 }                       /* count(1) */
28 template<class T>
29 void WithBrace(T *a)
31   while (!a->done())   
32     { 
33       a->run();         /* count(#####) */
34     }
35 }                       /* count(1) */
37 A *func(A *a)
39   WithoutBrace(a);
40   WithBrace(a);
41   return a;
44 int main() {
45   A a(0);
46   func(&a);
47   return 0;
50 /* { dg-final { run-gcov gcov-5.C } } */