It turns out that, even if cgraph_node::expand_thunk happily overrides the
DECL_IGNORED_P setting on the thunk from the front-end, this is necessary when
the thunk is initially a back-end thunk and then turned into a GIMPLE thunk,
e.g. because of inlining, to play nice with early debug info generation.
So the patch reinstates the overriding, but only when expanding to GIMPLE.
Tested on x86-64/Linux, applied on the mainline as obvious.
2018-10-10 Eric Botcazou <ebotca...@adacore.com>
PR middle-end/87574
* cgraphunit.c (cgraph_node::expand_thunk): Force DECL_IGNORED_P on
the thunk when expanding to GIMPLE.
2018-10-10 Eric Botcazou <ebotca...@adacore.com>
* g++.dg/other/pr87574.C: New test.
--
Eric Botcazou
Index: cgraphunit.c
===================================================================
--- cgraphunit.c (revision 264986)
+++ cgraphunit.c (working copy)
@@ -1862,6 +1862,12 @@ cgraph_node::expand_thunk (bool output_a
DECL_ARGUMENTS. In this case force_gimple_thunk is true. */
if (in_lto_p && !force_gimple_thunk)
get_untransformed_body ();
+
+ /* We need to force DECL_IGNORED_P when the thunk is created
+ after early debug was run. */
+ if (force_gimple_thunk)
+ DECL_IGNORED_P (thunk_fndecl) = 1;
+
a = DECL_ARGUMENTS (thunk_fndecl);
current_function_decl = thunk_fndecl;
// PR middle-end/87574
// Testcase by David Binderman <dcb...@hotmail.com>
// { dg-do compile }
// { dg-options "-O2 -g -Wno-return-type" }
class a {
public:
virtual ~a();
};
class c {
public:
enum j {};
virtual j d() = 0;
};
class e : a, c {
j d();
};
class f;
class g {
public:
static g *h();
f *i();
};
class f {
public:
template <class b> b *l(int);
};
c::j e::d() {}
void m() {
for (int k;;)
g::h()->i()->l<c>(k)->d();
}