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]

[cs] PATCH to handle C_TYPE_INCOMPLETE_VARS


Checked into the compile-server branch.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


2003-12-12  Per Bothner  <pbothner@apple.com>

	* c-decl.c (finish_struct):  Move C_TYPE_INCOMPLETE_VARS processing to
	(finish_incomplete_vars):  ... this new function.
	(restore_fragment_bindings):  Call finish_incomplete_vars.  Needed if
	one compilation defines a tag, and another restores it as an incomplete
	structure-type-references, uses it for decls, and then restores the
	tag definition, at which point we need to complete those decls.

Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.417.2.10
diff -u -p -r1.417.2.10 c-decl.c
--- c-decl.c	12 Dec 2003 05:06:14 -0000	1.417.2.10
+++ c-decl.c	13 Dec 2003 05:26:01 -0000
@@ -330,6 +330,7 @@ static void clone_underlying_type (tree)
 static bool flexible_array_type_p (tree);
 static hashval_t link_hash_hash	(const void *);
 static int link_hash_eq (const void *, const void *);
+static void finish_incomplete_vars (tree, int);
 
 /* States indicating how grokdeclarator() should handle declspecs marked
    with __attribute__((deprecated)).  An object declared as
@@ -459,9 +460,13 @@ restore_fragment_bindings (tree bindings
 		  TYPE_FIELDS (type) = NULL_TREE;
 		}
 	    }
-	  if (fields != NULL)
+	  if (size != NULL_TREE)
 	    {
-	      for (x = TYPE_MAIN_VARIANT (type); x; x = TYPE_NEXT_VARIANT (x))
+	      x = TYPE_MAIN_VARIANT (type);
+	      if (TREE_CODE (x) == RECORD_TYPE
+		  || TREE_CODE (x) == UNION_TYPE)
+		finish_incomplete_vars (x, 1);
+	      for (; x; x = TYPE_NEXT_VARIANT (x))
 		{
 		  TYPE_FIELDS (x) = fields;
 		  TYPE_SIZE (x) = size;
@@ -5328,11 +5333,22 @@ finish_struct (tree t, tree fieldlist, t
       warning ("union cannot be made transparent");
     }
 
-  /* If this structure or union completes the type of any previous
-     variable declaration, lay it out and output its rtl.  */
-  for (x = C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t));
-       x;
-       x = TREE_CHAIN (x))
+  finish_incomplete_vars (TYPE_MAIN_VARIANT (t), toplevel);
+
+  /* Finish debugging output for this type.  */
+  rest_of_type_compilation (t, toplevel);
+
+  return t;
+}
+
+/* If this structure or union completes the type of any previous
+   variable declaration, lay it out and output its rtl.  */
+
+static void
+finish_incomplete_vars (tree t, int toplevel)
+{
+  tree x;
+  for (x = C_TYPE_INCOMPLETE_VARS (t);  x;  x = TREE_CHAIN (x))
     {
       tree decl = TREE_VALUE (x);
       if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
@@ -5347,12 +5363,7 @@ finish_struct (tree t, tree fieldlist, t
 	    expand_decl (decl);
 	}
     }
-  C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t)) = 0;
-
-  /* Finish debugging output for this type.  */
-  rest_of_type_compilation (t, toplevel);
-
-  return t;
+  C_TYPE_INCOMPLETE_VARS (t) = 0;
 }
 
 /* Lay out the type T, and its element type, and so on.  */

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