summaryrefslogtreecommitdiff
path: root/gcc/tree-diagnostic.c
diff options
context:
space:
mode:
authormanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-24 19:21:21 +0000
committermanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-24 19:21:21 +0000
commitc224fa34178e236fd7e96702e5bcae0bc27f8506 (patch)
tree03ddeb5ba2cc3f34ce5c10654d25ba5d70db6fb7 /gcc/tree-diagnostic.c
parent7eaf7f7fb0f84466fcfa38db893d654155d99688 (diff)
downloadgcc-c224fa34178e236fd7e96702e5bcae0bc27f8506.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186780 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-diagnostic.c')
-rw-r--r--gcc/tree-diagnostic.c71
1 files changed, 70 insertions, 1 deletions
diff --git a/gcc/tree-diagnostic.c b/gcc/tree-diagnostic.c
index b4b60dc44f9..c811fe9cdd2 100644
--- a/gcc/tree-diagnostic.c
+++ b/gcc/tree-diagnostic.c
@@ -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;
+}