tree-pretty-print.h (default_tree_printer): Do not declare.
authorManuel López-Ibáñez <manu@gcc.gnu.org>
Tue, 24 Apr 2012 19:21:21 +0000 (19:21 +0000)
committerManuel López-Ibáñez <manu@gcc.gnu.org>
Tue, 24 Apr 2012 19:21:21 +0000 (19:21 +0000)
2012-04-24  Manuel López-Ibáñez  <manu@gcc.gnu.org>

gcc/
* tree-pretty-print.h (default_tree_printer): Do not declare.
* tree-diagnostic.c: Include tree-pretty-print.h, tree-pass.h and
intl.h.
(default_tree_diagnostic_starter): Make static.
(default_tree_printer): Move to here. Make static.
(tree_diagnostics_defaults): New.
* tree-diagnostic.h (default_tree_diagnostic_starter): Do not declare.
* tree.c (free_lang_data): Use tree_diagnostics_defaults.
* toplev.c: Do not include tree-pass.h.
(default_tree_printer): Move from here.
(general_init): Use tree_diagnostics_defaults.

From-SVN: r186780

gcc/ChangeLog
gcc/toplev.c
gcc/tree-diagnostic.c
gcc/tree-diagnostic.h
gcc/tree-pretty-print.h
gcc/tree.c

index 96e0fb9723af813ebb291bb47c1482041793c5a0..3be610718c81d881197d4c300ec597a89d0a0c6a 100644 (file)
@@ -1,3 +1,17 @@
+2012-04-24  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       * tree-pretty-print.h (default_tree_printer): Do not declare.
+       * tree-diagnostic.c: Include tree-pretty-print.h, tree-pass.h and
+       intl.h.
+       (default_tree_diagnostic_starter): Make static.
+       (default_tree_printer): Move to here. Make static.
+       (tree_diagnostics_defaults): New.
+       * tree-diagnostic.h (default_tree_diagnostic_starter): Do not declare.
+       * tree.c (free_lang_data): Use tree_diagnostics_defaults.
+       * toplev.c: Do not include tree-pass.h.
+       (default_tree_printer): Move from here.
+       (general_init): Use tree_diagnostics_defaults.
+
 2012-04-24  Chao-ying Fu  <fu@mips.com>
 
        * config.gcc (mips64*-*-linux*): Append mips/linux-common.h to tm_file.
index 574af3bc1608e1fa799e77246076d8247dc552bd..3d9e1626b8057d36542847f589cfe9ef4aef4e2e 100644 (file)
@@ -74,7 +74,6 @@ along with GCC; see the file COPYING3.  If not see
 #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"
@@ -962,63 +961,6 @@ init_asm_output (const char *name)
     }
 }
 
-/* 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 *
@@ -1163,13 +1105,15 @@ general_init (const char *argv0)
   /* 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
index b4b60dc44f9be2a0273b6456ab51bc0dc862d276..c811fe9cdd2ec24c6f8723d160d63f4855e8510c 100644 (file)
@@ -25,10 +25,13 @@ along with GCC; see the file COPYING3.  If not see
 #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.  */
@@ -40,7 +43,7 @@ diagnostic_report_current_function (diagnostic_context *context,
   lang_hooks.print_error_function (context, input_filename, diagnostic);
 }
 
-void
+static void
 default_tree_diagnostic_starter (diagnostic_context *context,
                                 diagnostic_info *diagnostic)
 {
@@ -227,3 +230,69 @@ virt_loc_aware_diagnostic_finalizer (diagnostic_context *context,
                                   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 6b8e8e6e4375f0267471dda94dbca4b02563540e..819792caaa72a9e3cd1b54bdd8695df2e7cc77ee 100644 (file)
@@ -49,9 +49,10 @@ along with GCC; see the file COPYING3.  If not see
        ? 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 49e78987d4aab86ed0e0ab233a2007ce970fb702..d622e5194157c30445499199e782e31c5dd54ff7 100644 (file)
@@ -50,10 +50,6 @@ 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);
 
index b0d52b2e0e9aa63f21a4deb7a24366b2c0202462..7837d45e11b062f41284c57ac8026967c4d95de7 100644 (file)
@@ -38,7 +38,7 @@ along with GCC; see the file COPYING3.  If not see
 #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"
@@ -5255,9 +5255,7 @@ free_lang_data (void)
      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;
 }