diff options
author | David Malcolm <dmalcolm@redhat.com> | 2018-11-15 14:32:41 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2018-11-15 14:32:41 +0000 |
commit | 478dd60ddcf17773ebd1af367c9dcaee2401f797 (patch) | |
tree | 9504f45599f1a9e4f54c7ffbbe41f73bc1c04e12 /gcc/common.opt | |
parent | ef190c93b07f04d61e28d70bb9a360fd2f3efbde (diff) | |
download | gcc-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/common.opt')
-rw-r--r-- | gcc/common.opt | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/common.opt b/gcc/common.opt index 73065f5..72a7135 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1277,6 +1277,23 @@ Enum(diagnostic_color_rule) String(always) Value(DIAGNOSTICS_COLOR_YES) EnumValue Enum(diagnostic_color_rule) String(auto) Value(DIAGNOSTICS_COLOR_AUTO) +fdiagnostics-format= +Common Joined RejectNegative Enum(diagnostics_output_format) +-fdiagnostics-format=[text|json] Select output format + +; Required for these enum values. +SourceInclude +diagnostic.h + +Enum +Name(diagnostics_output_format) Type(int) + +EnumValue +Enum(diagnostics_output_format) String(text) Value(DIAGNOSTICS_OUTPUT_FORMAT_TEXT) + +EnumValue +Enum(diagnostics_output_format) String(json) Value(DIAGNOSTICS_OUTPUT_FORMAT_JSON) + fdiagnostics-parseable-fixits Common Var(flag_diagnostics_parseable_fixits) Print fix-it hints in machine-readable form. |