diff -Nru gcc-4.0.2.orig/gcc/c-decl.c gcc-4.0.2/gcc/c-decl.c
--- gcc-4.0.2.orig/gcc/c-decl.c	2005-11-14 10:43:28.000000000 +0100
+++ gcc-4.0.2/gcc/c-decl.c	2005-11-14 10:52:53.000000000 +0100
@@ -7527,6 +7527,7 @@
 c_write_global_declarations_1 (tree globals)
 {
   tree decl;
+  bool reconsider;
 
   /* Process the decls in the order they were written.  */
   for (decl = globals; decl; decl = TREE_CHAIN (decl))
@@ -7545,9 +7546,19 @@
 	}
 
       wrapup_global_declaration_1 (decl);
-      wrapup_global_declaration_2 (decl);
-      check_global_declaration_1 (decl);
     }
+
+  do
+    {
+      reconsider = false;
+      for (decl = globals; decl; decl = TREE_CHAIN (decl))
+	reconsider |= wrapup_global_declaration_2 (decl);
+    }
+  while (reconsider);
+
+  for (decl = globals; decl; decl = TREE_CHAIN (decl))
+    check_global_declaration_1 (decl);
+
 }
 
 /* A subroutine of c_write_global_declarations Emit debug information for each
diff -Nru gcc-4.0.2.orig/gcc/testsuite/gcc.c-torture/execute/20050929-1.c gcc-4.0.2/gcc/testsuite/gcc.c-torture/execute/20050929-1.c
--- gcc-4.0.2.orig/gcc/testsuite/gcc.c-torture/execute/20050929-1.c	1970-01-01 01:00:00.000000000 +0100
+++ gcc-4.0.2/gcc/testsuite/gcc.c-torture/execute/20050929-1.c	2005-11-14 10:53:43.000000000 +0100
@@ -0,0 +1,20 @@
+/* PR middle-end/24109 */
+
+extern void abort (void);
+
+struct A { int i; int j; };
+struct B { struct A *a; struct A *b; };
+struct C { struct B *c; struct A *d; };
+struct C e = { &(struct B) { &(struct A) { 1, 2 }, &(struct A) { 3, 4 } }, &(struct A) { 5, 6 } };
+
+int
+main (void)
+{
+  if (e.c->a->i != 1 || e.c->a->j != 2)
+    abort ();
+  if (e.c->b->i != 3 || e.c->b->j != 4)
+    abort ();
+  if (e.d->i != 5 || e.d->j != 6)
+    abort ();
+  return 0;
+}
