diff options
author | manu <manu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-24 22:01:50 +0000 |
---|---|---|
committer | manu <manu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-24 22:01:50 +0000 |
commit | ff213692b8c78012d6d828f4e6efadf4084ad82e (patch) | |
tree | 583600b9236c0cc119d94c2ca69748fab0849e77 /gcc/diagnostic.c | |
parent | 920f8b671c22e0e339ce8f2e82a1d5842b571d10 (diff) | |
download | gcc-ff213692b8c78012d6d828f4e6efadf4084ad82e.tar.gz |
2012-10-24 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c++/54928
* tree-diagnostic.c (maybe_unwind_expanded_macro_loc):
Use diagnostic_append_note.
* diagnostic.c (diagnostic_build_prefix): Make diagnostic const.
(default_diagnostic_finalizer): Do not destroy prefix here.
(diagnostic_report_diagnostic): Destroy it here.
(diagnostic_append_note): New.
* diagnostic.h (diagnostic_append_note): Declare.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@192786 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/diagnostic.c')
-rw-r--r-- | gcc/diagnostic.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index b2ba901cfe4..ff210dcaed4 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -208,7 +208,7 @@ diagnostic_set_info (diagnostic_info *diagnostic, const char *gmsgid, responsible for freeing the memory. */ char * diagnostic_build_prefix (diagnostic_context *context, - diagnostic_info *diagnostic) + const diagnostic_info *diagnostic) { static const char *const diagnostic_kind_text[] = { #define DEFINE_DIAGNOSTIC_KIND(K, T) (T), @@ -519,10 +519,9 @@ default_diagnostic_starter (diagnostic_context *context, } void -default_diagnostic_finalizer (diagnostic_context *context, +default_diagnostic_finalizer (diagnostic_context *context ATTRIBUTE_UNUSED, diagnostic_info *diagnostic ATTRIBUTE_UNUSED) { - pp_destroy_prefix (context->printer); } /* Interface to specify diagnostic kind overrides. Returns the @@ -759,6 +758,7 @@ diagnostic_report_diagnostic (diagnostic_context *context, pp_output_formatted_text (context->printer); diagnostic_show_locus (context, diagnostic); (*diagnostic_finalizer (context)) (context, diagnostic); + pp_destroy_prefix (context->printer); pp_newline_and_flush (context->printer); diagnostic_action_after_output (context, diagnostic); diagnostic->message.format_spec = saved_format_spec; @@ -821,6 +821,29 @@ verbatim (const char *gmsgid, ...) va_end (ap); } +/* Add a note with text GMSGID and with LOCATION to the diagnostic CONTEXT. */ +void +diagnostic_append_note (diagnostic_context *context, + location_t location, + const char * gmsgid, ...) +{ + diagnostic_info diagnostic; + va_list ap; + + va_start (ap, gmsgid); + diagnostic_set_info (&diagnostic, gmsgid, &ap, location, DK_NOTE); + if (context->inhibit_notes_p) + return; + pp_set_prefix (context->printer, + diagnostic_build_prefix (context, &diagnostic)); + pp_newline (context->printer); + pp_format (context->printer, &diagnostic.message); + pp_output_formatted_text (context->printer); + pp_destroy_prefix (context->printer); + diagnostic_show_locus (context, &diagnostic); + va_end(ap); +} + bool emit_diagnostic (diagnostic_t kind, location_t location, int opt, const char *gmsgid, ...) |