From 40a431fa1b60546aa99d26090ecdda5e56e108f5 Mon Sep 17 00:00:00 2001 From: dmalcolm Date: Fri, 2 Sep 2016 19:41:17 +0000 Subject: Add -fdiagnostics-generate-patch gcc/ChangeLog: * common.opt (fdiagnostics-generate-patch): New option. * diagnostic.c: Include "edit-context.h". (diagnostic_initialize): Initialize context->edit_context_ptr. (diagnostic_finish): Delete context->edit_context_ptr. (diagnostic_report_diagnostic): Add fix-it hints from the diagnostic to context->edit_context_ptr, if any. * diagnostic.h (class edit_context): Add forward decl. (struct diagnostic_context): Add field "edit_context_ptr". * doc/invoke.texi (Diagnostic Message Formatting Options): Add -fdiagnostics-generate-patch. (-fdiagnostics-generate-patch): New item. * toplev.c: Include "edit-context.h". (process_options): Set global_dc->edit_context_ptr to a new edit_context if the options need one. (toplev::main): Handle -fdiagnostics-generate-patch by using global_dc->edit_context_ptr. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic-test-show-locus-generate-patch.c: New test case. * gcc.dg/plugin/plugin.exp (plugin_test_list): Add diagnostic-test-show-locus-generate-patch.c to the sources for diagnostic_plugin_test_show_locus.c. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239965 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/toplev.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gcc/toplev.c') diff --git a/gcc/toplev.c b/gcc/toplev.c index 26079047219..4da5627b350 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -76,6 +76,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-chkp.h" #include "omp-low.h" #include "hsa.h" +#include "edit-context.h" #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) #include "dbxout.h" @@ -1221,6 +1222,9 @@ process_options (void) /* Some machines may reject certain combinations of options. */ targetm.target_option.override (); + if (flag_diagnostics_generate_patch) + global_dc->edit_context_ptr = new edit_context (); + /* Avoid any informative notes in the second run of -fcompare-debug. */ if (flag_compare_debug) diagnostic_inhibit_notes (global_dc); @@ -2147,6 +2151,16 @@ toplev::main (int argc, char **argv) emit some diagnostics here. */ invoke_plugin_callbacks (PLUGIN_FINISH, NULL); + if (flag_diagnostics_generate_patch) + { + gcc_assert (global_dc->edit_context_ptr); + + pretty_printer (pp); + pp_show_color (&pp) = pp_show_color (global_dc->printer); + global_dc->edit_context_ptr->print_diff (&pp, true); + pp_flush (&pp); + } + diagnostic_finish (global_dc); finalize_plugins (); -- cgit v1.2.1 From 751a5629c133b11e3757219bdea39428bf500dda Mon Sep 17 00:00:00 2001 From: jakub Date: Mon, 5 Sep 2016 18:14:25 +0000 Subject: PR middle-end/77475 * toplev.c (process_options): Temporarily set input_location to UNKNOWN_LOCATION around targetm.target_option.override () call. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239994 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/toplev.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gcc/toplev.c') diff --git a/gcc/toplev.c b/gcc/toplev.c index 4da5627b350..66099ec7d23 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1220,7 +1220,10 @@ process_options (void) no_backend = lang_hooks.post_options (&main_input_filename); /* Some machines may reject certain combinations of options. */ + location_t saved_location = input_location; + input_location = UNKNOWN_LOCATION; targetm.target_option.override (); + input_location = saved_location; if (flag_diagnostics_generate_patch) global_dc->edit_context_ptr = new edit_context (); -- cgit v1.2.1