]> gcc.gnu.org Git - gcc.git/commitdiff
Propagate the source location from a template function's definition to
authorJeffrey Yasskin <jyasskin@google.com>
Wed, 24 Nov 2010 00:24:54 +0000 (00:24 +0000)
committerJeffrey Yasskin <jyasskin@gcc.gnu.org>
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.

From-SVN: r167104

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

index 6daf31b38a802077de574ff6e8dfe84cac39786b..f5d612d98be22195c61071782b50cdf6c165849f 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 3e8b62cd5216064f3d856e7f6dd529a94e45f47b..c4b4a03d7f4d6bcce9553bacd64835c2d4ae8a0d 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 63c2d0bb341769dc8c655131b34d141f192031f1..bb3cada80d77447fcffaa21f6a5062337b1790a5 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();
+}
This page took 0.112691 seconds and 5 git commands to generate.