From 3e7c21b1929359743cc2a941ec09e82be95128ce Mon Sep 17 00:00:00 2001 From: rguenth Date: Wed, 12 Oct 2016 14:37:53 +0000 Subject: [PATCH] 2016-10-12 Richard Biener PR debug/77947 * cgraphunit.c (analyze_functions): Preserve cgraph nodes function context. * g++.dg/torture/pr77947.C: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241053 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/cgraphunit.c | 13 ++++++++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/torture/pr77947.C | 29 +++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr77947.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e709adb091b..3fb6a77068b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-10-12 Richard Biener + + PR debug/77947 + * cgraphunit.c (analyze_functions): Preserve cgraph nodes + function context. + 2016-10-12 Thomas Schwinge * lto-streamer.c: Fix LTO_STREAMER_DEBUG build. diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index abcb35dea63..4fa518d27c6 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -1117,15 +1117,22 @@ analyze_functions (bool first_time) } /* If decl is a clone of an abstract function, - mark that abstract function so that we don't release its body. - The DECL_INITIAL() of that abstract function declaration - will be later needed to output debug info. */ + mark that abstract function so that we don't release its body. + The DECL_INITIAL() of that abstract function declaration + will be later needed to output debug info. */ if (DECL_ABSTRACT_ORIGIN (decl)) { cgraph_node *origin_node = cgraph_node::get_create (DECL_ABSTRACT_ORIGIN (decl)); origin_node->used_as_abstract_origin = true; } + /* Preserve a functions function context node. It will + later be needed to output debug info. */ + if (tree fn = decl_function_context (decl)) + { + cgraph_node *origin_node = cgraph_node::get_create (fn); + enqueue_node (origin_node); + } } else { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4a991d9ec43..10a8e35b8bf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-10-12 Richard Biener + + PR debug/77947 + * g++.dg/torture/pr77947.C: New testcase. + 2016-10-12 Pierre-Marie de Rodat * gnat.dg/debug8.adb: New testcase. diff --git a/gcc/testsuite/g++.dg/torture/pr77947.C b/gcc/testsuite/g++.dg/torture/pr77947.C new file mode 100644 index 00000000000..3c8a24a16c6 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr77947.C @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-additional-options "-g" } + +class A +{ +public: + virtual bool m_fn1 () const = 0; +}; +class B +{ + const A *m_fn2 () const; +}; +inline const A * +B::m_fn2 () const +{ + class C : A + { + bool + m_fn1 () const + { + } + C () {} + }; +} +void +fn1 (A &p1) +{ + p1.m_fn1 (); +} -- 2.11.4.GIT