public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Wrong line number for the closing brace of template functions
@ 2007-08-06 17:36 Seongbae Park (박성배, 朴成培)
  2007-08-06 18:11 ` Mark Mitchell
  0 siblings, 1 reply; 3+ messages in thread
From: Seongbae Park (박성배, 朴成培) @ 2007-08-06 17:36 UTC (permalink / raw)
  To: gcc-patches, Mark Mitchell, Nathan Sidwell

[-- Attachment #1: Type: text/plain, Size: 924 bytes --]

Hi,

The included testcase in the patch demonstrates the bug,
which is that the last source line of a template function was not
propagated correctly to template function instances,
leading to all template functions to report wrong coverage count
for the implicit "return".

Note that the patch is supposed to be applied on top of my previous patch:

http://gcc.gnu.org/ml/gcc-patches/2007-07/msg01953.html

(Please consider this email as another ping for that patch as well)

The bootstrap is done, and regtest is under way.
If all tests look clean, OK for mainline ?


gcc/testsuite/ChangeLog:

2007-08-06  Seongbae Park <seongbae.park@gmail.com>

        * g++.dg/gcov/gcov-5.C: New test.


gcc/cp/ChangeLog:

2007-08-06  Seongbae Park <seongbae.park@gmail.com>

        * pt.c (instantiate_decl): Set input_location
        for the function end.

-- 
#pragma ident "Seongbae Park, compiler, http://seongbae.blogspot.com"

[-- Attachment #2: template-end-of-func.patch --]
[-- Type: text/x-patch, Size: 1960 bytes --]

Index: gcc/testsuite/g++.dg/gcov/gcov-5.C
===================================================================
--- gcc/testsuite/g++.dg/gcov/gcov-5.C	(revision 0)
+++ gcc/testsuite/g++.dg/gcov/gcov-5.C	(revision 0)
@@ -0,0 +1,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 } } */
Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c	(revision 127246)
+++ gcc/cp/pt.c	(working copy)
@@ -14438,6 +14438,12 @@ instantiate_decl (tree d, int defer_ok,
 		   tf_warning_or_error, tmpl,
 		   /*integral_constant_expression_p=*/false);
 
+      /* Make sure the current input_location
+         is set correctly to the end of the function
+	 - this makes finish_function to set
+	 function_end_locus of this specialization correctly. */
+      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;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-08-06 18:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-06 17:36 [PATCH] Wrong line number for the closing brace of template functions Seongbae Park (박성배, 朴成培)
2007-08-06 18:11 ` Mark Mitchell
2007-08-06 18:47   ` Dave Korn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).