diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9351048440c..03599dfff0e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2014-08-21 Manuel López-Ibáñez + + PR fortran/44054 + * diagnostic.c (default_diagnostic_finalizer): Move caret printing + to here ... + (diagnostic_report_diagnostic): ... from here. + * toplev.c (general_init): Move code to c-family. + 2014-08-20 Bill Schmidt * df.h (web_entry_base): Replace existing struct web_entry with a diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 8119b06e650..e8673b54d28 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,10 @@ +2014-08-21 Manuel López-Ibáñez + + PR fortran/44054 + * c-opts.c: Include tree-diagnostics.h. + (c_diagnostic_finalizer): New. + (c_common_initialize_diagnostics): Use it. + 2014-08-20 Manuel López-Ibáñez PR preprocessor/51303 diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 2b423e2174b..5cae2b8e8d1 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see #include "toplev.h" #include "langhooks.h" #include "diagnostic.h" +#include "tree-diagnostic.h" /* for virt_loc_aware_diagnostic_finalizer */ #include "intl.h" #include "cppdefault.h" #include "incpath.h" @@ -164,6 +165,19 @@ c_common_option_lang_mask (void) return lang_flags[c_language]; } +/* Diagnostic finalizer for C/C++/Objective-C/Objective-C++. */ +static void +c_diagnostic_finalizer (diagnostic_context *context, + diagnostic_info *diagnostic) +{ + diagnostic_show_locus (context, diagnostic); + /* By default print macro expansion contexts in the diagnostic + finalizer -- for tokens resulting from macro expansion. */ + virt_loc_aware_diagnostic_finalizer (context, diagnostic); + pp_destroy_prefix (context->printer); + pp_newline_and_flush (context->printer); +} + /* Common diagnostics initialization. */ void c_common_initialize_diagnostics (diagnostic_context *context) @@ -179,7 +193,7 @@ c_common_initialize_diagnostics (diagnostic_context *context) diagnostic message. */ diagnostic_prefixing_rule (context) = DIAGNOSTICS_SHOW_PREFIX_ONCE; } - + diagnostic_finalizer (context) = c_diagnostic_finalizer; context->opt_permissive = OPT_fpermissive; } diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6d61f75b804..27e22497357 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-08-21 Manuel López-Ibáñez + + PR fortran/44054 + * error.c (cp_diagnostic_finalizer): Delete. + (init_error): Do not set diagnostic_finalizer here. + 2014-08-19 Marek Polacek PR c++/62153 diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 2ce6490681b..9f0498dbb99 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -99,7 +99,6 @@ static void print_instantiation_partial_context (diagnostic_context *, struct tinst_level *, location_t); static void cp_diagnostic_starter (diagnostic_context *, diagnostic_info *); -static void cp_diagnostic_finalizer (diagnostic_context *, diagnostic_info *); static void cp_print_error_function (diagnostic_context *, diagnostic_info *); static bool cp_printer (pretty_printer *, text_info *, const char *, @@ -109,7 +108,7 @@ void init_error (void) { diagnostic_starter (global_dc) = cp_diagnostic_starter; - diagnostic_finalizer (global_dc) = cp_diagnostic_finalizer; + /* diagnostic_finalizer is already c_diagnostic_finalizer. */ diagnostic_format_decoder (global_dc) = cp_printer; new (cxx_pp) cxx_pretty_printer (); @@ -3041,14 +3040,6 @@ cp_diagnostic_starter (diagnostic_context *context, diagnostic)); } -static void -cp_diagnostic_finalizer (diagnostic_context *context, - diagnostic_info *diagnostic) -{ - virt_loc_aware_diagnostic_finalizer (context, diagnostic); - pp_destroy_prefix (context->printer); -} - /* Print current function onto BUFFER, in the process of reporting a diagnostic message. Called from cp_diagnostic_starter. */ static void diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index 62447212d49..9e6bfe52bff 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -554,9 +554,12 @@ default_diagnostic_starter (diagnostic_context *context, } void -default_diagnostic_finalizer (diagnostic_context *context ATTRIBUTE_UNUSED, - diagnostic_info *diagnostic ATTRIBUTE_UNUSED) +default_diagnostic_finalizer (diagnostic_context *context, + diagnostic_info *diagnostic) { + diagnostic_show_locus (context, diagnostic); + pp_destroy_prefix (context->printer); + pp_newline_and_flush (context->printer); } /* Interface to specify diagnostic kind overrides. Returns the @@ -805,10 +808,7 @@ diagnostic_report_diagnostic (diagnostic_context *context, pp_format (context->printer, &diagnostic->message); (*diagnostic_starter (context)) (context, diagnostic); 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; diagnostic->x_data = NULL; diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9d939ea35c3..d47bffc2a7f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2014-08-21 Manuel López-Ibáñez + + PR fortran/44054 + * error.c (gfc_diagnostic_finalizer): Call default finalizer. + 2014-08-20 Joost VandeVondele * options.c (gfc_init_options_struct): assert that the frontend sets diff --git a/gcc/fortran/error.c b/gcc/fortran/error.c index e3f44f75505..7aab46d4311 100644 --- a/gcc/fortran/error.c +++ b/gcc/fortran/error.c @@ -1016,9 +1016,10 @@ gfc_diagnostic_starter (diagnostic_context *context, } static void -gfc_diagnostic_finalizer (diagnostic_context *context ATTRIBUTE_UNUSED, - diagnostic_info *diagnostic ATTRIBUTE_UNUSED) +gfc_diagnostic_finalizer (diagnostic_context *context, + diagnostic_info *diagnostic) { + default_diagnostic_finalizer(context, diagnostic); } /* Give a warning about the command-line. */ diff --git a/gcc/toplev.c b/gcc/toplev.c index aaad68816e4..a7f4b581f42 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1115,11 +1115,6 @@ general_init (const char *argv0) /* Set a default printer. Language specific initializations will override it later. */ 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;