* [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
* Re: [PATCH] Wrong line number for the closing brace of template functions
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
0 siblings, 1 reply; 3+ messages in thread
From: Mark Mitchell @ 2007-08-06 18:11 UTC (permalink / raw)
To: "Seongbae Park (박성배,
朴成培)"
Cc: gcc-patches, Nathan Sidwell
Seongbae Park (ë°ì±ë°°, æ´æå¹) wrote:
> 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.
This patch is OK, after Nathan finishes reviewing the other one.
However, this comment:
+ /* 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. */
could be written better as:
/* Set the current input_location to the end of the function so
that finish_function knows where we are. */
The "makes x to set y" construct is not grammatical.
Thanks,
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] Wrong line number for the closing brace of template functions
2007-08-06 18:11 ` Mark Mitchell
@ 2007-08-06 18:47 ` Dave Korn
0 siblings, 0 replies; 3+ messages in thread
From: Dave Korn @ 2007-08-06 18:47 UTC (permalink / raw)
To: 'Mark Mitchell',
'"Seongbae Park (박성배,
朴成培)"'
Cc: 'gcc-patches', 'Nathan Sidwell'
On 06 August 2007 19:11, Mark Mitchell wrote:
> However, this comment:
>
> + /* 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. */
>
> could be written better as:
>
> /* Set the current input_location to the end of the function so
> that finish_function knows where we are. */
>
> The "makes x to set y" construct is not grammatical.
FYI, anyone whose first language isn't English:
The very similar construction "causes x to set y" is grammatical, and although "makes" and "causes" mean the same in this context, only "causes" may be used in that construct. "makes x set y" would also be grammatical. (I don't know why "causes" requires an infinitive (actually, probably a gerund) and "makes" requires a finite verb phrase, but there you go).
cheers,
DaveK
--
Can't think of a witty .sigline today....
^ 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).