blob: 9ada41802caa18381b7c90cb384b2d3cfcd3f5bb (
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
42
43
44
45
46
47
48
49
50
|
/* Check that execution counts for template functions
are reported correctly by gcov. */
#include <stdio.h>
#include <stdlib.h>
/* { dg-options "-fprofile-arcs -ftest-coverage -fno-inline" } */
/* { dg-do run { target native } } */
class A {
int count;
public:
A(int c) { count = c; }
void func(void) { printf("func\n"); }
bool done(void) {
return (count == 0) ? true : (count-- != 0);
}
void run(void) { abort(); }
};
//typedef A T;
template<class T>
void WithoutBrace(T *a) {
while (!a->done())
a->run(); /* count(#####) */
} /* count(1) */
template<class T>
void WithBrace(T *a)
{
while (!a->done())
{
a->run(); /* count(#####) */
}
} /* count(1) */
A *func(A *a)
{
WithoutBrace(a);
WithBrace(a);
return a;
}
int main() {
A a(0);
func(&a);
return 0;
}
/* { dg-final { run-gcov gcov-5.C } } */
|