From 75407da35c2a03618a8a5fe2d111efaa8437f3a2 Mon Sep 17 00:00:00 2001 From: Seongbae Park Date: Thu, 16 Aug 2007 17:36:01 +0000 Subject: [PATCH] gcov-5.C: New test. gcc/testsuite/ChangeLog: 2007-08-16 Seongbae Park * g++.dg/gcov/gcov-5.C: New test. gcc/cp/ChangeLog: 2007-08-16 Seongbae Park * pt.c (instantiate_decl): Set input_location for the function end. From-SVN: r127563 --- gcc/cp/ChangeLog | 5 +++ gcc/cp/pt.c | 4 +++ gcc/testsuite/ChangeLog | 4 +++ gcc/testsuite/g++.dg/gcov/gcov-5.C | 50 ++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 gcc/testsuite/g++.dg/gcov/gcov-5.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c2b043f409f..89172af26d7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2007-08-16 Seongbae Park + + * pt.c (instantiate_decl): Set input_location + for the function end. + 2007-08-16 Kaveh R. Ghazi * cp-objcp-common.c (cxx_warn_unused_global_decl, cp_expr_size): diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 68cd9a580a2..76d35186f1e 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -14440,6 +14440,10 @@ instantiate_decl (tree d, int defer_ok, tf_warning_or_error, tmpl, /*integral_constant_expression_p=*/false); + /* Set the current input_location to the end of the function + so that finish_function knows where we are. */ + input_location = DECL_STRUCT_FUNCTION (code_pattern)->function_end_locus; + /* We don't need the local specializations any more. */ htab_delete (local_specializations); local_specializations = saved_local_specializations; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 37532f52131..2e4dfb357aa 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2007-08-16 Seongbae Park + + * g++.dg/gcov/gcov-5.C: New test. + 2007-08-16 Seongbae Park * g++.dg/gcov/gcov-4.C: New test. diff --git a/gcc/testsuite/g++.dg/gcov/gcov-5.C b/gcc/testsuite/g++.dg/gcov/gcov-5.C new file mode 100644 index 00000000000..9ada41802ca --- /dev/null +++ b/gcc/testsuite/g++.dg/gcov/gcov-5.C @@ -0,0 +1,50 @@ +/* Check that execution counts for template functions + are reported correctly by gcov. */ + +#include +#include + +/* { 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 +void WithoutBrace(T *a) { + while (!a->done()) + a->run(); /* count(#####) */ +} /* count(1) */ + +template +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 } } */ -- 2.30.2