Mark Mitchell <mark@codesourcery.com> writes:
PR 8391 contains this code:
inline void h(const Outer &o)
{
struct Local : public Outer::Inner {
virtual bool f() {};
};
Local l;
o.g(l);
}
When we try to emit the body of Local::f (the function in the struct
inside h), we don't actually emit assembly code because of this code
in rest_of_compilation:
/* If this is nested inside an inlined external function, pretend
it was only declared. Since we cannot inline such functions,
generating code for this one is not only not necessary but will
confuse some debugging output writers. */
for (parent = DECL_CONTEXT (current_function_decl);
parent != NULL_TREE;
parent = get_containing_scope (parent))
if (TREE_CODE (parent) == FUNCTION_DECL
&& DECL_INLINE (parent) && DECL_EXTERNAL (parent))
{
DECL_INITIAL (decl) = 0;
goto exit_rest_of_compilation;
}
This logic is wrong for C++; we need to emit Local::f.
I believe the rationale behind this code is that Local::f can't be
used from this translation unit, since the function won't be inlined.
It will be emitted when the out-of-line copy of the function is emitted.
Will this function really not be inlined?