2007-08-16 Seongbae Park <seongbae.park@gmail.com>
* g++.dg/gcov/gcov-5.C: New test.
gcc/cp/ChangeLog:
2007-08-16 Seongbae Park <seongbae.park@gmail.com>
* pt.c (instantiate_decl): Set input_location
for the function end.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127563
138bc75d-0d04-0410-961f-
82ee72b054a4
+2007-08-16 Seongbae Park <seongbae.park@gmail.com>
+
+ * pt.c (instantiate_decl): Set input_location
+ for the function end.
+
2007-08-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* cp-objcp-common.c (cxx_warn_unused_global_decl, cp_expr_size):
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;
+2007-08-16 Seongbae Park <seongbae.park@gmail.com>
+
+ * g++.dg/gcov/gcov-5.C: New test.
+
2007-08-16 Seongbae Park <seongbae.park@gmail.com>
* g++.dg/gcov/gcov-4.C: New test.
--- /dev/null
+/* 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 } } */