diff options
author | David Malcolm <dmalcolm@redhat.com> | 2024-03-19 13:57:35 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2024-03-19 13:57:35 -0400 |
commit | 0bf99b1b7eda2f4c34b9f56b895980ea1c261765 (patch) | |
tree | 7f01f8103b589fd373f5f482c24015e13abde390 /gcc/config/m32c | |
parent | bc91e3870e9c984c180b478a3449a9a2e56cd107 (diff) | |
download | gcc-0bf99b1b7eda2f4c34b9f56b895980ea1c261765.zip gcc-0bf99b1b7eda2f4c34b9f56b895980ea1c261765.tar.gz gcc-0bf99b1b7eda2f4c34b9f56b895980ea1c261765.tar.bz2 |
diagnostics: fix corrupt json/SARIF on stderr [PR114348]
Various values of -fdiagnostics-format= request machine-readable output
on stderr, using JSON, but in various places we use fnotice to write
free-form text to stderr, such as "compilation terminated", leading to
corrupt JSON.
Fix by having fnotice skip the output for such cases.
gcc/ChangeLog:
PR middle-end/114348
* diagnostic-format-json.cc
(json_stderr_output_format::machine_readable_stderr_p): New.
(json_file_output_format::machine_readable_stderr_p): New.
* diagnostic-format-sarif.cc
(sarif_stream_output_format::machine_readable_stderr_p): New.
(sarif_file_output_format::machine_readable_stderr_p): New.
* diagnostic.cc (diagnostic_context::action_after_output): Move
"fnotice" to before "finish" call, so that we still have the
diagnostic_context.
(fnotice): Bail out if the user requested one of the
machine-readable diagnostic output formats on stderr.
* diagnostic.h
(diagnostic_output_format::machine_readable_stderr_p): New pure
virtual function.
(diagnostic_text_output_format::machine_readable_stderr_p): New.
(diagnostic_context::get_output_format): New accessor.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/config/m32c')
0 files changed, 0 insertions, 0 deletions