OSDN Git Service

Propagate the source location from a template function's definition to
authorjyasskin <jyasskin@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 24 Nov 2010 00:24:54 +0000 (00:24 +0000)
committerjyasskin <jyasskin@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 24 Nov 2010 00:24:54 +0000 (00:24 +0000)
any already-instantiated declarations.

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 test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167104 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/dwarf2/pr46527.C [new file with mode: 0644]

index 6daf31b..f5d612d 100644 (file)
@@ -1,3 +1,9 @@
+2010-11-23  Jeffrey Yasskin <jyasskin@google.com>
+
+       PR c++/46527
+       * pt.c (instantiate_decl): Propagate the template's location to
+       its instance.
+
 2010-11-20  Joseph Myers  <joseph@codesourcery.com>
 
        * name-lookup.c (handle_namespace_attrs): Don't check
index 3e8b62c..c4b4a03 100644 (file)
@@ -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 63c2d0b..bb3cada 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-23  Jeffrey Yasskin <jyasskin@google.com>
+
+       PR c++/46527
+       * g++.dg/debug/dwarf2/pr46527.C: New test.
+
 2010-11-23  Iain Sandoe  <iains@gcc.gnu.org>
 
        * gcc.dg/darwin-cfstring-1.c: Adjust format messages.
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pr46527.C b/gcc/testsuite/g++.dg/debug/dwarf2/pr46527.C
new file mode 100644 (file)
index 0000000..dfc983b
--- /dev/null
@@ -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();
+}