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]

C patch not to put arg_info structures in DECL_ARGUMENTS


This patch is part of the C90 implementation project for GCC 3.5
(current status being maintained at
<http://www.srcf.ucam.org/~jsm28/gcc/#c90status>).

This particular patch is one fragment preliminary to the replacement
of trees as datastructures for declarators, going in separately
because the decoupling of ObjC from declarators isn't yet in mainline.
(I wouldn't normally split such a patch up into quite so many little
bits.)

When non-tree structures are used for declarators, DECL_ARGUMENTS
can't be overloaded to store them.  This patch arranges for arg_info
structures to be stored in current_function_arg_info instead.  The
saving and restoring in struct language_function is paranoia for such
nested function misuses as in bug 17023; we should give a meaningful
error for it rather than an ICE, but also avoid corrupting these
datastructures.

Bootstrapped with no regressions on i686-pc-linux-gnu together with
the other such fragment sent at this time.  Applied to mainline.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
  http://www.srcf.ucam.org/~jsm28/gcc/#c90status - status of C90 for GCC 3.5
    jsm@polyomino.org.uk (personal mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)

2004-08-30  Joseph S. Myers  <jsm@polyomino.org.uk>

	* c-tree.h (struct language_function): Add arg_info element.
	* c-decl.c (current_function_arg_info): New.
	(grokdeclarator, store_parm_decls): Use it instead of
	DECL_ARGUMENTS.
	(c_push_function_context, c_pop_function_context): Save and
	restore it.

diff -rupN GCC.orig/gcc/c-decl.c GCC/gcc/c-decl.c
--- GCC.orig/gcc/c-decl.c	2004-08-29 19:03:58.000000000 +0000
+++ GCC/gcc/c-decl.c	2004-08-30 14:50:45.000000000 +0000
@@ -104,6 +104,11 @@ static int enum_overflow;
 
 static location_t current_function_prototype_locus;
 
+/* The argument information structure for the function currently being
+   defined.  */
+
+static GTY(()) tree current_function_arg_info;
+
 /* The current statement tree.  */
 
 static GTY(()) struct stmt_tree_s c_stmt_tree;
@@ -4704,10 +4709,9 @@ grokdeclarator (tree declarator, tree de
 	  = !(specbits & ((1 << (int) RID_STATIC) | (1 << (int) RID_AUTO)));
 
 	/* For a function definition, record the argument information
-	   block in DECL_ARGUMENTS where store_parm_decls will look
-	   for it.  */
+	   block where store_parm_decls will look for it.  */
 	if (funcdef_flag)
-	  DECL_ARGUMENTS (decl) = arg_info;
+	  current_function_arg_info = arg_info;
 
 	if (defaulted_int)
 	  C_FUNCTION_IMPLICIT_INT (decl) = 1;
@@ -6352,16 +6356,18 @@ void
 store_parm_decls (void)
 {
   tree fndecl = current_function_decl;
+  bool proto;
 
   /* The argument information block for FNDECL.  */
-  tree arg_info = DECL_ARGUMENTS (fndecl);
+  tree arg_info = current_function_arg_info;
+  current_function_arg_info = 0;
 
   /* True if this definition is written with a prototype.  Note:
      despite C99 6.7.5.3p14, we can *not* treat an empty argument
      list in a function definition as equivalent to (void) -- an
      empty argument list specifies the function has no parameters,
      but only (void) sets up a prototype for future calls.  */
-  bool proto = ARG_INFO_TYPES (arg_info) != 0;
+  proto = ARG_INFO_TYPES (arg_info) != 0;
 
   if (proto)
     store_parm_decls_newstyle (fndecl, arg_info);
@@ -6645,6 +6651,7 @@ c_push_function_context (struct function
   p->x_break_label = c_break_label;
   p->x_cont_label = c_cont_label;
   p->x_switch_stack = c_switch_stack;
+  p->arg_info = current_function_arg_info;
   p->returns_value = current_function_returns_value;
   p->returns_null = current_function_returns_null;
   p->returns_abnormally = current_function_returns_abnormally;
@@ -6673,6 +6680,7 @@ c_pop_function_context (struct function 
   c_break_label = p->x_break_label;
   c_cont_label = p->x_cont_label;
   c_switch_stack = p->x_switch_stack;
+  current_function_arg_info = p->arg_info;
   current_function_returns_value = p->returns_value;
   current_function_returns_null = p->returns_null;
   current_function_returns_abnormally = p->returns_abnormally;
diff -rupN GCC.orig/gcc/c-tree.h GCC/gcc/c-tree.h
--- GCC.orig/gcc/c-tree.h	2004-08-29 19:03:58.000000000 +0000
+++ GCC/gcc/c-tree.h	2004-08-30 14:37:41.000000000 +0000
@@ -135,6 +135,7 @@ struct language_function GTY(())
   tree x_break_label;
   tree x_cont_label;
   struct c_switch * GTY((skip)) x_switch_stack;
+  tree arg_info;
   int returns_value;
   int returns_null;
   int returns_abnormally;


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