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]

[PATCH] Fix expand_expr/ADDR_EXPR ICE on IA-64 (take 2)


Hi!

> So I think something else is wrong here.

Is this better? The issue was that finish_struct laied just x's type, but
not already the decl itself.
While looking at it, I found that n_incomplete in the global binding level
was always at least 1 (bumped for builtin void TYPE_DECL), so every
finish_struct was walking over the whole current_binding_level->names list.
This patch makes sure that it is bumped only for the decls which are
actually handled by finish_struct (the only user of that information)
and that for ARRAY_TYPEs n_incomplete is decreased again.
Ok to commit?

2001-11-30  Jakub Jelinek  <jakub@redhat.com>

	* c-decl.c (pushdecl): Only increase n_incomplete if pushed decl's
	type is RECORD_TYPE, UNION_TYPE or ARRAY_TYPE thereof.
	(finish_struct): Break the loop if n_incomplete went to 0.
	For ARRAY_TYPE, if it is not TYPE_DECL, layout the decl too.

	* gcc.c-torture/compile/20011130-1.c: New test.

--- gcc/testsuite/gcc.c-torture/compile/20011130-1.c.jj	Fri Nov 30 13:40:05 2001
+++ gcc/testsuite/gcc.c-torture/compile/20011130-1.c	Fri Nov 30 13:14:17 2001
@@ -0,0 +1,7 @@
+extern struct S x[];
+struct S { int i; };
+char *bar (const struct S *);
+void foo (void)
+{
+  bar (x);
+}
--- gcc/c-decl.c.jj	Tue Nov 27 17:15:23 2001
+++ gcc/c-decl.c	Fri Nov 30 16:11:40 2001
@@ -2487,7 +2487,15 @@ pushdecl (x)
 	 incomplete type.  */
       if (TREE_TYPE (x) != error_mark_node
 	  && !COMPLETE_TYPE_P (TREE_TYPE (x)))
-	++b->n_incomplete;
+	{
+	  tree element = TREE_TYPE (x);
+
+	  while (TREE_CODE (element) == ARRAY_TYPE)
+	    element = TREE_TYPE (element);
+	  if (TREE_CODE (element) == RECORD_TYPE
+	      || TREE_CODE (element) == UNION_TYPE)
+	    ++b->n_incomplete;
+	}
     }
 
   /* Put decls on list in reverse order.
@@ -5720,7 +5728,8 @@ finish_struct (t, fieldlist, attributes)
 	      rest_of_decl_compilation (decl, NULL, toplevel, 0);
 	      if (! toplevel)
 		expand_decl (decl);
-	      --current_binding_level->n_incomplete;
+	      if (--current_binding_level->n_incomplete == 0)
+		break;
 	    }
 	  else if (!COMPLETE_TYPE_P (TREE_TYPE (decl))
 		   && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
@@ -5729,7 +5738,19 @@ finish_struct (t, fieldlist, attributes)
 	      while (TREE_CODE (element) == ARRAY_TYPE)
 		element = TREE_TYPE (element);
 	      if (element == t)
-		layout_array_type (TREE_TYPE (decl));
+		{
+		  layout_array_type (TREE_TYPE (decl));
+		  if (TREE_CODE (decl) != TYPE_DECL)
+		    {
+		      layout_decl (decl, 0);
+		      maybe_objc_check_decl (decl);
+		      rest_of_decl_compilation (decl, NULL, toplevel, 0);
+		      if (! toplevel)
+			expand_decl (decl);
+		    }
+		  if (--current_binding_level->n_incomplete == 0)
+		    break;
+		}
 	    }
 	}
     }

	Jakub


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