gcc/gcc/fortran
David Malcolm 478dd60ddc 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
2018-11-15 14:32:41 +00:00
..
arith.c re PR fortran/86111 (ICE in gfc_arith_concat, at fortran/arith.c:985) 2018-10-06 18:20:14 +00:00
arith.h
array.c
bbt.c
ChangeLog Machine-readable diagnostic output (PR other/19165) 2018-11-15 14:32:41 +00:00
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 re PR fortran/54613 ([F08] Add FINDLOC plus support MAXLOC/MINLOC with KIND=/BACK=) 2018-10-28 11:05:05 +00:00
class.c
config-lang.in
constructor.c
constructor.h
convert.c
cpp.c Eliminate source_location in favor of location_t 2018-11-13 20:05:03 +00:00
cpp.h
data.c
data.h
decl.c re PR fortran/46020 (Improve error string for BIND(C) diagnostic for len>1 character return type) 2018-11-02 20:20:43 +00:00
dependency.c re PR fortran/40196 ([F03] [F08] Type parameter inquiry (str%len, a%kind) and Complex parts (z%re, z%im)) 2018-11-01 19:36:08 +00:00
dependency.h
dump-parse-tree.c re PR fortran/40196 ([F03] [F08] Type parameter inquiry (str%len, a%kind) and Complex parts (z%re, z%im)) 2018-11-01 19:36:08 +00:00
error.c Machine-readable diagnostic output (PR other/19165) 2018-11-15 14:32:41 +00:00
expr.c re PR fortran/40196 ([F03] [F08] Type parameter inquiry (str%len, a%kind) and Complex parts (z%re, z%im)) 2018-11-01 19:36:08 +00:00
f95-lang.c
frontend-passes.c re PR fortran/87782 (runtime error: load of value 1818451807, which is not a valid value for type 'expr_t') 2018-11-01 19:50:14 +00:00
gfc-diagnostic.def
gfc-internals.texi
gfortran.h Eliminate source_location in favor of location_t 2018-11-13 20:05:03 +00:00
gfortran.texi re PR fortran/54613 ([F08] Add FINDLOC plus support MAXLOC/MINLOC with KIND=/BACK=) 2018-11-01 11:37:08 +00:00
gfortranspec.c Fix and document -r option 2018-09-20 20:38:24 +01:00
interface.c gfortran.h (gfc_str_startswith): New macro. 2018-09-20 21:33:05 +02:00
intrinsic.c re PR fortran/40196 ([F03] [F08] Type parameter inquiry (str%len, a%kind) and Complex parts (z%re, z%im)) 2018-11-01 19:36:08 +00:00
intrinsic.h re PR fortran/54613 ([F08] Add FINDLOC plus support MAXLOC/MINLOC with KIND=/BACK=) 2018-10-28 11:05:05 +00:00
intrinsic.texi re PR fortran/54613 ([F08] Add FINDLOC plus support MAXLOC/MINLOC with KIND=/BACK=) 2018-11-01 11:37:08 +00:00
invoke.texi
io.c
ioparm.def
iresolve.c re PR fortran/54613 ([F08] Add FINDLOC plus support MAXLOC/MINLOC with KIND=/BACK=) 2018-10-28 11:05:05 +00:00
iso-c-binding.def
iso-fortran-env.def
lang-specs.h
lang.opt
libgfortran.h
Make-lang.in Run selftests for C++ as well as C 2018-10-17 13:56:05 +00:00
match.c re PR fortran/40196 ([F03] [F08] Type parameter inquiry (str%len, a%kind) and Complex parts (z%re, z%im)) 2018-11-01 19:36:08 +00:00
match.h
matchexp.c
mathbuiltins.def
misc.c
module.c re PR fortran/40196 ([F03] [F08] Type parameter inquiry (str%len, a%kind) and Complex parts (z%re, z%im)) 2018-11-01 19:36:08 +00:00
openmp.c re PR fortran/87725 (OpenMP 4.5 clause schedule(simd,monotonic:static) not understood) 2018-10-25 09:56:55 +02:00
options.c gfortran.h (gfc_str_startswith): New macro. 2018-09-20 21:33:05 +02:00
parse.c
parse.h
primary.c re PR fortran/40196 ([F03] [F08] Type parameter inquiry (str%len, a%kind) and Complex parts (z%re, z%im)) 2018-11-01 19:36:08 +00:00
resolve.c re PR fortran/40196 ([F03] [F08] Type parameter inquiry (str%len, a%kind) and Complex parts (z%re, z%im)) 2018-11-01 19:36:08 +00:00
scanner.c
scanner.h
simplify.c re PR fortran/40196 ([F03] [F08] Type parameter inquiry (str%len, a%kind) and Complex parts (z%re, z%im)) 2018-11-01 19:36:08 +00:00
st.c
symbol.c
target-memory.c
target-memory.h
trans-array.c re PR fortran/40196 ([F03] [F08] Type parameter inquiry (str%len, a%kind) and Complex parts (z%re, z%im)) 2018-11-01 19:36:08 +00:00
trans-array.h
trans-common.c
trans-const.c
trans-const.h
trans-decl.c Fix hash-table violation in trans-decl.c. 2018-10-31 10:59:34 +00:00
trans-expr.c re PR fortran/40196 ([F03] [F08] Type parameter inquiry (str%len, a%kind) and Complex parts (z%re, z%im)) 2018-11-01 19:36:08 +00:00
trans-intrinsic.c re PR fortran/54613 ([F08] Add FINDLOC plus support MAXLOC/MINLOC with KIND=/BACK=) 2018-10-28 11:05:05 +00:00
trans-io.c
trans-openmp.c builtin-types.def (BT_FN_VOID_BOOL, [...]): New. 2018-11-08 18:13:04 +01:00
trans-stmt.c re PR fortran/58618 (Wrong code with character substring and ASSOCIATE) 2018-10-18 10:37:39 +00:00
trans-stmt.h
trans-types.c gimple-ssa-sprintf.c (format_string): Do not hardcode size of target's wchar_t. 2018-10-03 20:55:10 -06:00
trans-types.h
trans.c re PR fortran/70752 (Incorrect LEN for ALLOCATABLE CHARACTER) 2018-09-30 12:22:07 +00:00
trans.h re PR middle-end/41453 (use INTENT(out) for optimization) 2018-09-22 18:44:01 +00:00
types.def builtin-types.def (BT_FN_VOID_BOOL, [...]): New. 2018-11-08 18:13:04 +01:00