This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [3.4 PATCH] Fix inline nested functions (PR middle-end/15345,c/16450)


Jakub Jelinek wrote:

On Tue, Jul 20, 2004 at 03:30:53PM -0400, Jason Merrill wrote:


+ || (cgraph_n_nodes > 0 && cgraph_node (decl)->origin))


decl_function_context (decl) is the canonical way to test for nested.



Just to be clear, in C++, with:

void f() { struct S { void g() { } }; };

the "g" function will have a non-NULL decl_function_context, but is not
"nested" in the sense of GNU C nested functions; for example, "g" cannot
refer to automatic variables in "f".


It's not nested in the sense of needing a static chain, but it is nested in
the sense of being within the scope of f, which I think is what cgraph
wants to check.



Actually, it is not nested in the cgraph sense.
cgraph nesting is:
if (DECL_CONTEXT (decl) && TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL)


That makes sense to me.

The decl_function_context test is purely about the scope of names; it should not be relevant from a code-generation point of view.

--
Mark Mitchell
CodeSourcery, LLC
(916) 791-8304
mark@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]