478dd60ddc
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 |
||
---|---|---|
.. | ||
arith.c | ||
arith.h | ||
array.c | ||
bbt.c | ||
ChangeLog | ||
ChangeLog-2002 | ||
ChangeLog-2003 | ||
ChangeLog-2004 | ||
ChangeLog-2005 | ||
ChangeLog-2006 | ||
ChangeLog-2007 | ||
ChangeLog-2008 | ||
ChangeLog-2009 | ||
ChangeLog-2010 | ||
ChangeLog-2011 | ||
ChangeLog-2012 | ||
ChangeLog-2013 | ||
ChangeLog-2014 | ||
ChangeLog-2015 | ||
ChangeLog-2016 | ||
ChangeLog-2017 | ||
ChangeLog.ptr | ||
check.c | ||
class.c | ||
config-lang.in | ||
constructor.c | ||
constructor.h | ||
convert.c | ||
cpp.c | ||
cpp.h | ||
data.c | ||
data.h | ||
decl.c | ||
dependency.c | ||
dependency.h | ||
dump-parse-tree.c | ||
error.c | ||
expr.c | ||
f95-lang.c | ||
frontend-passes.c | ||
gfc-diagnostic.def | ||
gfc-internals.texi | ||
gfortran.h | ||
gfortran.texi | ||
gfortranspec.c | ||
interface.c | ||
intrinsic.c | ||
intrinsic.h | ||
intrinsic.texi | ||
invoke.texi | ||
io.c | ||
ioparm.def | ||
iresolve.c | ||
iso-c-binding.def | ||
iso-fortran-env.def | ||
lang-specs.h | ||
lang.opt | ||
libgfortran.h | ||
Make-lang.in | ||
match.c | ||
match.h | ||
matchexp.c | ||
mathbuiltins.def | ||
misc.c | ||
module.c | ||
openmp.c | ||
options.c | ||
parse.c | ||
parse.h | ||
primary.c | ||
resolve.c | ||
scanner.c | ||
scanner.h | ||
simplify.c | ||
st.c | ||
symbol.c | ||
target-memory.c | ||
target-memory.h | ||
trans-array.c | ||
trans-array.h | ||
trans-common.c | ||
trans-const.c | ||
trans-const.h | ||
trans-decl.c | ||
trans-expr.c | ||
trans-intrinsic.c | ||
trans-io.c | ||
trans-openmp.c | ||
trans-stmt.c | ||
trans-stmt.h | ||
trans-types.c | ||
trans-types.h | ||
trans.c | ||
trans.h | ||
types.def |