Index: gcc/tree-pretty-print.h
===================================================================
--- gcc/tree-pretty-print.h	(revision 186353)
+++ gcc/tree-pretty-print.h	(working copy)
@@ -48,13 +48,9 @@ extern void print_call_name (pretty_prin
 extern void debug_generic_expr (tree);
 extern void debug_generic_stmt (tree);
 extern void debug_tree_chain (tree);
 extern void percent_K_format (text_info *);
 extern void dump_function_header (FILE *, tree, int);
-
-/* In toplev.c  */
-extern bool default_tree_printer (pretty_printer *, text_info *, const char *,
-				  int, bool, bool, bool);
 /* In c-pretty-print.c  */
 extern void debug_c_tree (tree);
 
 #endif /* ! GCC_TREE_PRETTY_PRINT_H */
Index: gcc/tree-diagnostic.c
===================================================================
--- gcc/tree-diagnostic.c	(revision 186353)
+++ gcc/tree-diagnostic.c	(working copy)
@@ -23,14 +23,17 @@ along with GCC; see the file COPYING3.  
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
 #include "tree.h"
 #include "diagnostic.h"
+#include "tree-pretty-print.h"
 #include "tree-diagnostic.h"
+#include "tree-pass.h" /* TDF_DIAGNOSTIC */
 #include "langhooks.h"
 #include "langhooks-def.h"
 #include "vec.h"
+#include "intl.h"
 
 /* Prints out, if necessary, the name of the current function
    that caused an error.  Called from all error and warning functions.  */
 void
 diagnostic_report_current_function (diagnostic_context *context,
@@ -38,11 +41,11 @@ diagnostic_report_current_function (diag
 {
   diagnostic_report_current_module (context, diagnostic->location);
   lang_hooks.print_error_function (context, input_filename, diagnostic);
 }
 
-void
+static void
 default_tree_diagnostic_starter (diagnostic_context *context,
 				 diagnostic_info *diagnostic)
 {
   diagnostic_report_current_function (context, diagnostic);
   pp_set_prefix (context->printer, diagnostic_build_prefix (context,
@@ -225,5 +228,71 @@ virt_loc_aware_diagnostic_finalizer (dia
 {
   maybe_unwind_expanded_macro_loc (context, diagnostic,
 				   diagnostic->location,
 				   NULL);
 }
+
+/* Default tree printer.   Handles declarations only.  */
+static bool
+default_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
+		      int precision, bool wide, bool set_locus, bool hash)
+{
+  tree t;
+
+  /* FUTURE: %+x should set the locus.  */
+  if (precision != 0 || wide || hash)
+    return false;
+
+  switch (*spec)
+    {
+    case 'E':
+      t = va_arg (*text->args_ptr, tree);
+      if (TREE_CODE (t) == IDENTIFIER_NODE)
+	{
+	  pp_identifier (pp, IDENTIFIER_POINTER (t));
+	  return true;
+	}
+      break;
+
+    case 'D':
+      t = va_arg (*text->args_ptr, tree);
+      if (DECL_DEBUG_EXPR_IS_FROM (t) && DECL_DEBUG_EXPR (t))
+	t = DECL_DEBUG_EXPR (t);
+      break;
+
+    case 'F':
+    case 'T':
+      t = va_arg (*text->args_ptr, tree);
+      break;
+
+    case 'K':
+      percent_K_format (text);
+      return true;
+
+    default:
+      return false;
+    }
+
+  if (set_locus && text->locus)
+    *text->locus = DECL_SOURCE_LOCATION (t);
+
+  if (DECL_P (t))
+    {
+      const char *n = DECL_NAME (t)
+        ? identifier_to_locale (lang_hooks.decl_printable_name (t, 2))
+        : _("<anonymous>");
+      pp_string (pp, n);
+    }
+  else
+    dump_generic_node (pp, t, 0, TDF_DIAGNOSTIC, 0);
+
+  return true;
+}
+
+/* Sets CONTEXT to use language independent diagnostics.  */
+void
+tree_diagnostics_defaults (diagnostic_context *context)
+{
+  diagnostic_starter (context) = default_tree_diagnostic_starter;
+  diagnostic_finalizer (context) = default_diagnostic_finalizer;
+  diagnostic_format_decoder (context) = default_tree_printer;
+}
Index: gcc/tree-diagnostic.h
===================================================================
--- gcc/tree-diagnostic.h	(revision 186353)
+++ gcc/tree-diagnostic.h	(working copy)
@@ -47,11 +47,12 @@ along with GCC; see the file COPYING3.  
   diagnostic_context_auxiliary_data (DC)		\
     = (((DI) && diagnostic_abstract_origin (DI))	\
        ? diagnostic_abstract_origin (DI)		\
        : current_function_decl)
 
-void default_tree_diagnostic_starter (diagnostic_context *, diagnostic_info *);
-extern void diagnostic_report_current_function (diagnostic_context *,
-						diagnostic_info *);
+void diagnostic_report_current_function (diagnostic_context *,
+					 diagnostic_info *);
 void virt_loc_aware_diagnostic_finalizer (diagnostic_context *,
 					  diagnostic_info *);
+
+void tree_diagnostics_defaults (diagnostic_context *context);
 #endif /* ! GCC_TREE_DIAGNOSTIC_H */
Index: gcc/tree.c
===================================================================
--- gcc/tree.c	(revision 186353)
+++ gcc/tree.c	(working copy)
@@ -36,11 +36,11 @@ along with GCC; see the file COPYING3.  
 #include "flags.h"
 #include "tree.h"
 #include "tm_p.h"
 #include "function.h"
 #include "obstack.h"
-#include "toplev.h"
+#include "toplev.h" /* get_random_seed */
 #include "ggc.h"
 #include "hashtab.h"
 #include "filenames.h"
 #include "output.h"
 #include "target.h"
@@ -5244,13 +5244,11 @@ free_lang_data (void)
      name and only produce assembler names for local symbols.  Or rather
      make sure we never call decl_assembler_name on local symbols and
      devise a separate, middle-end private scheme for it.  */
 
   /* Reset diagnostic machinery.  */
-  diagnostic_starter (global_dc) = default_tree_diagnostic_starter;
-  diagnostic_finalizer (global_dc) = default_diagnostic_finalizer;
-  diagnostic_format_decoder (global_dc) = default_tree_printer;
+  tree_diagnostics_defaults (global_dc);
 
   return 0;
 }
 
 
Index: gcc/toplev.c
===================================================================
--- gcc/toplev.c	(revision 186353)
+++ gcc/toplev.c	(working copy)
@@ -72,11 +72,10 @@ along with GCC; see the file COPYING3.  
 #include "opts-diagnostic.h"
 #include "coverage.h"
 #include "value-prof.h"
 #include "alloc-pool.h"
 #include "tree-mudflap.h"
-#include "tree-pass.h"
 #include "gimple.h"
 #include "tree-ssa-alias.h"
 #include "plugin.h"
 
 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
@@ -959,67 +958,10 @@ init_asm_output (const char *name)
 	  putc ('\n', asm_out_file);
 	}
     }
 }
 
-/* Default tree printer.   Handles declarations only.  */
-bool
-default_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
-		      int precision, bool wide, bool set_locus, bool hash)
-{
-  tree t;
-
-  /* FUTURE: %+x should set the locus.  */
-  if (precision != 0 || wide || hash)
-    return false;
-
-  switch (*spec)
-    {
-    case 'E':
-      t = va_arg (*text->args_ptr, tree);
-      if (TREE_CODE (t) == IDENTIFIER_NODE)
-	{
-	  pp_identifier (pp, IDENTIFIER_POINTER (t));
-	  return true;
-	}
-      break;
-
-    case 'D':
-      t = va_arg (*text->args_ptr, tree);
-      if (DECL_DEBUG_EXPR_IS_FROM (t) && DECL_DEBUG_EXPR (t))
-	t = DECL_DEBUG_EXPR (t);
-      break;
-
-    case 'F':
-    case 'T':
-      t = va_arg (*text->args_ptr, tree);
-      break;
-
-    case 'K':
-      percent_K_format (text);
-      return true;
-
-    default:
-      return false;
-    }
-
-  if (set_locus && text->locus)
-    *text->locus = DECL_SOURCE_LOCATION (t);
-
-  if (DECL_P (t))
-    {
-      const char *n = DECL_NAME (t)
-        ? identifier_to_locale (lang_hooks.decl_printable_name (t, 2))
-        : _("<anonymous>");
-      pp_string (pp, n);
-    }
-  else
-    dump_generic_node (pp, t, 0, TDF_DIAGNOSTIC, 0);
-
-  return true;
-}
-
 /* A helper function; used as the reallocator function for cpp's line
    table.  */
 static void *
 realloc_for_line_map (void *ptr, size_t len)
 {
@@ -1160,17 +1102,19 @@ general_init (const char *argv0)
   identifier_to_locale_free = ggc_free;
 
   /* Initialize the diagnostics reporting machinery, so option parsing
      can give warnings and errors.  */
   diagnostic_initialize (global_dc, N_OPTS);
-  diagnostic_starter (global_dc) = default_tree_diagnostic_starter;
-  /* By default print macro expansion contexts in the diagnostic
-     finalizer -- for tokens resulting from macro macro expansion.  */
-  diagnostic_finalizer (global_dc) = virt_loc_aware_diagnostic_finalizer;
   /* Set a default printer.  Language specific initializations will
      override it later.  */
-  pp_format_decoder (global_dc->printer) = &default_tree_printer;
+  tree_diagnostics_defaults (global_dc);
+  /* FIXME: This should probably be moved to C-family
+     language-specific initializations.  */
+  /* By default print macro expansion contexts in the diagnostic
+     finalizer -- for tokens resulting from macro expansion.  */
+  diagnostic_finalizer (global_dc) = virt_loc_aware_diagnostic_finalizer;
+
   global_dc->show_caret
     = global_options_init.x_flag_diagnostics_show_caret;
   global_dc->show_option_requested
     = global_options_init.x_flag_diagnostics_show_option;
   global_dc->show_column
