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: [PATCH] DECL_NO_STATIC_CHAIN -> DECL_STATIC_CHAIN


On 09/23/2009 11:29 AM, Jakub Jelinek wrote:
Hi!

This is something we've been discussing on IRC today.  DECL_NO_STATIC_CHAIN
is ATM quite weird, C++/Ada FEs set it to 1 for new function decls, C leaves
it at the default 0, then tree-nested computes it, but before my
cgraph_lower_function patch committed today it has been only valid for
decl_function_context (fndecl) != NULL functions.

This patch changes it to DECL_STATIC_CHAIN, which defaults to 0 and just
tree-nested.c sets it on nested functions that need a static chain.
This worked for everything except gcc.dg/nested-fn-2.c, where
initializer_constant_valid_p is called by C FE and expects all C nested
fns to be rejected (but not C++, ...).  That's before tree-nested.c does its
job, so I had to change c-parser to also set DECL_STATIC_CHAIN on nested
functions.

I'd thought about making this change myself, but chickened out.


@@ -1323,6 +1323,7 @@ c_parser_declaration_or_fndef (c_parser
       if (nested)
 	{
 	  tree decl = current_function_decl;
+	  DECL_STATIC_CHAIN (decl) = 1;

I think a comment is definitely required here, noting that this will be reset by tree-nested.c if the chain isn't needed.


Don't you need something similar for the Ada frontend? Someone ought to be able to create an Ada testcase similar to nested-fn-2.c...

       if (dump_file
           && (dump_flags & TDF_DETAILS)
-	  && DECL_NO_STATIC_CHAIN (info->context))
-	fprintf (dump_file, "Resetting no-static-chain for %s\n",
+	  && !DECL_STATIC_CHAIN (info->context))
+	fprintf (dump_file, "Resetting static-chain for %s\n",
 		 lang_hooks.decl_printable_name (info->context, 2));

"Setting static-chain for %s" is better wording now.


Otherwise this looks ok.


r~



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