diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-04-26 13:23:35 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-04-26 13:23:35 +0000 |
commit | e20ea85b2bb2d755dfd35912c7481bf3638fd51c (patch) | |
tree | 9d1ce987b6de5496a2df0ca0d2c2b72db2b2d75e /gcc/tree-diagnostic.c | |
parent | 77a3387dd148b81882d77ea3f6b995c1ebef7a32 (diff) | |
download | gcc-e20ea85b2bb2d755dfd35912c7481bf3638fd51c.tar.gz |
2012-04-26 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 186872 using svnmerge
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@186874 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-diagnostic.c')
-rw-r--r-- | gcc/tree-diagnostic.c | 89 |
1 files changed, 76 insertions, 13 deletions
diff --git a/gcc/tree-diagnostic.c b/gcc/tree-diagnostic.c index b4b60dc44f9..48c78000703 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) { @@ -92,23 +95,18 @@ DEF_VEC_ALLOC_O (loc_map_pair, heap); test.c:5:3: note: expanded from here test.c:5:14: note: in expansion of macro 'SHIFTL' test.c:8:3: note: expanded from here - test.c:8:3: note: in expansion of macro 'MULT2' + test.c:8:3: note: in expansion of macro 'MULT' test.c:13:3: note: expanded from here The part that goes from the third to the eighth line of this diagnostic (the lines containing the 'note:' string) is called the unwound macro expansion trace. That's the part generated by this - function. - - If FIRST_EXP_POINT_MAP is non-null, *FIRST_EXP_POINT_MAP is set to - the map of the location in the source that first triggered the - macro expansion. This must be an ordinary map. */ + function. */ static void maybe_unwind_expanded_macro_loc (diagnostic_context *context, diagnostic_info *diagnostic, - source_location where, - const struct line_map **first_exp_point_map) + source_location where) { const struct line_map *map; VEC(loc_map_pair,heap) *loc_vec = NULL; @@ -143,8 +141,8 @@ maybe_unwind_expanded_macro_loc (diagnostic_context *context, where = linemap_unwind_toward_expansion (line_table, where, &map); } while (linemap_macro_expansion_map_p (map)); - if (first_exp_point_map) - *first_exp_point_map = map; + /* Now map is set to the map of the location in the source that + first triggered the macro expansion. This must be an ordinary map. */ /* Walk LOC_VEC and print the macro expansion trace, unless the first macro which expansion triggered this trace was expanded @@ -224,6 +222,71 @@ virt_loc_aware_diagnostic_finalizer (diagnostic_context *context, diagnostic_info *diagnostic) { maybe_unwind_expanded_macro_loc (context, diagnostic, - diagnostic->location, - NULL); + diagnostic->location); +} + +/* 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; } |