This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Use the definition's source location even for already-instantiated templates (PR c++/46527)


Here's a new version that also sets the location of the template_decl.
It's still running the x86_64-linux testsuite, but I won't commit
until that passes.

On Fri, Nov 19, 2010 at 11:04 PM, Jeffrey Yasskin <jyasskin@google.com> wrote:
> This patch propagates the source location from a template function's
> definition to any already-instantiated declarations. It doesn't also
> copy it to the template_decl because that wasn't necessary to fix the
> bug, but I'm happy to do so if the experts think I should..
>
> 2010-11-19 ?Jeffrey Yasskin ?<jyasskin@google.com>
> ? ? ? ?PR c++/46527
> ? ? ? ?* gcc/cp/pt.c (instantiate_decl): Propagate the
> ? ? ? ?template's location to its instance.
>
> ? ? ? ?* gcc/testsuite/g++.dg/debug/dwarf2/pr46527.C: New.
>
> You can also review this at http://codereview.appspot.com/3233041/
>
> Thanks,
> Jeffrey
>
Index: gcc/testsuite/g++.dg/debug/dwarf2/pr46527.C
===================================================================
--- gcc/testsuite/g++.dg/debug/dwarf2/pr46527.C	(revision 0)
+++ gcc/testsuite/g++.dg/debug/dwarf2/pr46527.C	(revision 0)
@@ -0,0 +1,18 @@
+// Origin: PR 46527
+// { dg-do compile }
+// { dg-options "-g -O0 -dA" }
+
+template <typename T> struct Struct {
+  double defined_later();
+};
+struct WrapperStruct {
+  Struct<double> ClassInstantiated;
+};
+template <typename T> double
+Struct<T>::defined_later()  // { dg-function-on-line {_ZN6StructIdE13defined_laterEv} }
+{
+  return 1;
+}
+void InstantiateMethod() {
+  Struct<double>().defined_later();
+}
Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c	(revision 166973)
+++ gcc/cp/pt.c	(working copy)
@@ -17152,6 +17152,8 @@ instantiate_decl (tree d, int defer_ok,
       && !DECL_NOT_REALLY_EXTERN (d))
     mark_definable (d);
 
+  DECL_SOURCE_LOCATION (td) = DECL_SOURCE_LOCATION (code_pattern);
+  DECL_SOURCE_LOCATION (d) = DECL_SOURCE_LOCATION (code_pattern);
   input_location = DECL_SOURCE_LOCATION (d);
 
   /* If D is a member of an explicitly instantiated class template,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]