aboutsummaryrefslogtreecommitdiff
path: root/gcc/gcc.c
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2018-11-15 14:32:41 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2018-11-15 14:32:41 +0000
commit478dd60ddcf17773ebd1af367c9dcaee2401f797 (patch)
tree9504f45599f1a9e4f54c7ffbbe41f73bc1c04e12 /gcc/gcc.c
parentef190c93b07f04d61e28d70bb9a360fd2f3efbde (diff)
downloadgcc-478dd60ddcf17773ebd1af367c9dcaee2401f797.zip
gcc-478dd60ddcf17773ebd1af367c9dcaee2401f797.tar.gz
gcc-478dd60ddcf17773ebd1af367c9dcaee2401f797.tar.bz2
Machine-readable diagnostic output (PR other/19165)
This patch implements a -fdiagnostics-format=json option which converts the diagnostics to be output to stderr in a JSON format; see the documentation in invoke.texi. Logically-related diagnostics are nested at the JSON level, using the auto_diagnostic_group mechanism. gcc/ChangeLog: PR other/19165 * Makefile.in (OBJS): Move json.o to... (OBJS-libcommon): ...here and add diagnostic-format-json.o. * common.opt (fdiagnostics-format=): New option. (diagnostics_output_format): New enum. * diagnostic-format-json.cc: New file. * diagnostic.c (default_diagnostic_final_cb): New function, taken from start of diagnostic_finish. (diagnostic_initialize): Initialize final_cb to default_diagnostic_final_cb. (diagnostic_finish): Move "being treated as errors" messages to default_diagnostic_final_cb. Call any final_cb. (default_diagnostic_finalizer): Add diagnostic_t param. (diagnostic_report_diagnostic): Pass "orig_diag_kind" to diagnostic_finalizer callback. * diagnostic.h (enum diagnostics_output_format): New enum. (diagnostic_finalizer_fn): Reimplement, adding diagnostic_t param. (struct diagnostic_context): Add "final_cb". (default_diagnostic_finalizer): Add diagnostic_t param. (diagnostic_output_format_init): New decl. * doc/invoke.texi (-fdiagnostics-format): New option. * dwarf2out.c (gen_producer_string): Ignore OPT_fdiagnostics_format_. * gcc.c (driver_handle_option): Handle OPT_fdiagnostics_format_. * lto-wrapper.c (append_diag_options): Ignore it. * opts.c (common_handle_option): Handle it. gcc/c-family/ChangeLog: PR other/19165 * c-opts.c (c_diagnostic_finalizer): Add diagnostic_t param. gcc/fortran/ChangeLog: PR other/19165 * error.c (gfc_diagnostic_finalizer): Add diagnostic_t param. gcc/jit/ChangeLog: PR other/19165 * dummy-frontend.c (jit_begin_diagnostic): Add diagnostic_t param. gcc/testsuite/ChangeLog: PR other/19165 * c-c++-common/diagnostic-format-json-1.c: New test. * c-c++-common/diagnostic-format-json-2.c: New test. * c-c++-common/diagnostic-format-json-3.c: New test. * c-c++-common/diagnostic-format-json-4.c: New test. * c-c++-common/diagnostic-format-json-5.c: New test. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c (custom_diagnostic_finalizer): Add diagnostic_t param. * gcc.dg/plugin/location_overflow_plugin.c (verify_unpacked_ranges): Likewise. (verify_no_columns): Likewise. * gfortran.dg/diagnostic-format-json-1.F90: New test. * gfortran.dg/diagnostic-format-json-2.F90: New test. * gfortran.dg/diagnostic-format-json-3.F90: New test. From-SVN: r266186
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r--gcc/gcc.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/gcc.c b/gcc/gcc.c
index c0d17eb..afc18b3 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -4001,6 +4001,11 @@ driver_handle_option (struct gcc_options *opts,
diagnostic_color_init (dc, value);
break;
+ case OPT_fdiagnostics_format_:
+ diagnostic_output_format_init (dc,
+ (enum diagnostics_output_format)value);
+ break;
+
case OPT_Wa_:
{
int prev, j;