From 653d3aa04002bb2bcf00b2c5b5285275661d80cd Mon Sep 17 00:00:00 2001 From: jyasskin Date: Wed, 24 Nov 2010 00:24:54 +0000 Subject: [PATCH] Propagate the source location from a template function's definition to 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 | 6 ++++++ gcc/cp/pt.c | 2 ++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/debug/dwarf2/pr46527.C | 18 ++++++++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/pr46527.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6daf31b38a8..f5d612d98be 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2010-11-23 Jeffrey Yasskin + + PR c++/46527 + * pt.c (instantiate_decl): Propagate the template's location to + its instance. + 2010-11-20 Joseph Myers * name-lookup.c (handle_namespace_attrs): Don't check diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 3e8b62cd521..c4b4a03d7f4 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 63c2d0bb341..bb3cada80d7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-11-23 Jeffrey Yasskin + + PR c++/46527 + * g++.dg/debug/dwarf2/pr46527.C: New test. + 2010-11-23 Iain Sandoe * 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 index 00000000000..dfc983b177d --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/pr46527.C @@ -0,0 +1,18 @@ +// Origin: PR 46527 +// { dg-do compile } +// { dg-options "-g -O0 -dA" } + +template struct Struct { + double defined_later(); +}; +struct WrapperStruct { + Struct ClassInstantiated; +}; +template double +Struct::defined_later() // { dg-function-on-line {_ZN6StructIdE13defined_laterEv} } +{ + return 1; +} +void InstantiateMethod() { + Struct().defined_later(); +} -- 2.11.0