diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1e3e5ae1d5eadacdac8613ce34dc67b57c995bdb..aec351d0ab24d3a26032e2aa32ac0b96ca8b1970 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,4 +1,11 @@
+2003-09-13  Richard Henderson  <rth@redhat.com>
+
+	* cgraphunit.c (cgraph_assemble_pending_functions): Export.
+	(cgraph_finalize_function): Revert TREE_ASM_WRITTEN check.
+	* cgraph.h: Update.
+
 2003-09-12  Dale Johannesen  <dalej@apple.com>
+
 	* config/rs6000/rs6000.c: Fix typos in previous.
 
 2003-09-12  Ziemowit Laski  <zlaski@apple.com>
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 3ec89b606592851a865a952bc9afd9b71b0271b2..eb747d57d374d4d372f92f1a4e8639494c9ee848 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -168,6 +168,7 @@ void cgraph_varpool_finalize_decl (tree);
 bool cgraph_varpool_assemble_pending_decls (void);
 
 /* In cgraphunit.c  */
+bool cgraph_assemble_pending_functions (void);
 void cgraph_finalize_function (tree, bool);
 void cgraph_finalize_compilation_unit (void);
 void cgraph_create_edges (tree, tree);
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 3519359e9bf0fd8dc2f7afb73bcca433ea455d2b..f615d1bafa4312622463d3c901b88bc4f4c320c8 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -122,7 +122,8 @@ decide_is_function_needed (struct cgraph_node *node, tree decl)
 
 /* When not doing unit-at-a-time, output all functions enqueued.
    Return true when such a functions were found.  */
-static bool
+
+bool
 cgraph_assemble_pending_functions (void)
 {
   bool output = false;
@@ -136,9 +137,12 @@ cgraph_assemble_pending_functions (void)
 
       cgraph_nodes_queue = cgraph_nodes_queue->next_needed;
       if (!n->origin && !DECL_EXTERNAL (n->decl))
-	cgraph_expand_function (n);
-      output = true;
+	{
+	  cgraph_expand_function (n);
+	  output = true;
+	}
     }
+
   return output;
 }
 
@@ -164,7 +168,13 @@ cgraph_finalize_function (tree decl, bool nested)
 	 ??? It may make more sense to use one body for inlining and other
 	 body for expanding the function but this is dificult to do.  */
 
-      if (TREE_ASM_WRITTEN (decl))
+      /* If node->output is set, then this is a unit-at-a-time compilation
+	 and we have already begun whole-unit analysis.  This is *not*
+	 testing for whether we've already emitted the function.  That
+	 case can be sort-of legitimately seen with real function 
+	 redefinition errors.  I would argue that the front end should
+	 never present us with such a case, but don't enforce that for now.  */
+      if (node->output)
 	abort ();
 
       /* Reset our datastructures so we can analyze the function again.  */
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f9a7339c03f10be83b5567a1b8e4a58914b2f6b1..832b6d4256beadeacffdc035c2792e9c4d1e8f5f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2003-09-13  Richard Henderson  <rth@redhat.com>
+
+	* decl2.c (finish_file): Check cgraph_assemble_pending_functions
+	during relaxation loop.
+
 2003-09-11  David Edelsohn  <edelsohn@gnu.org>
 
 	* decl2.c (var_finalized_p): Swap arms of conditional.
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 6f30cf9b35bfa39f245c3f24720ed1663d0850f7..16991f3ca7d00f307fd12b82d577a8f357fcfccb 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -2863,6 +2863,9 @@ finish_file ()
 	  && wrapup_global_declarations (&VARRAY_TREE (pending_statics, 0),
 					 pending_statics_used))
 	reconsider = true;
+
+      if (cgraph_assemble_pending_functions ())
+	reconsider = true;
     } 
   while (reconsider);