https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116613
--- Comment #24 from Kamil Dudka <kdudka at redhat dot com> ---
(In reply to David Malcolm from comment #21)
> (In reply to David Malcolm from comment #20)
> > How about another option
> > -fdiagnostics-set-output=
> > that would work like
> > -fdiagnostics-add-output=
> > but rather than appending to the list of outputs, simply replaces anything
> > in the existing list?
I think this would solve the problem for OSH (and eliminate the need to create
unneeded JSON files).
> Now I think about it, that's only going to help for diagnostics that happen
> before the -fdiagnostics-{add,set}-output= param is processed.
I do not understand this part. Could you please provide an example where this
would not work as expected.
> FWIW SARIF has a distinction between a "result" and a "notification" where
> the former refer to the software under test, and the latter to the testing
> (e.g. a "tool configuration notification" could be "I can't read the config
> file to start this run"). Currently GCC doesn't make such a distinction;
> perhaps it should.
I did not know about this but it seems to work only partially. When gcc is
given a non-existing file name, it is recorded in the SARIF file as a result:
% gcc does-not-exist.c -fdiagnostics-add-output="sarif:file=msg.sarif"
cc1: fatal error: does-not-exist.c: No such file or directory
compilation terminated.
% csgrep msg.sarif
Error: COMPILER_WARNING:
<unknown>: warning[fatal error]: does-not-exist.c: No such file or directory
However, when gcc is given an unsupported flag, the SARIF file is not created
at all:
% gcc xxx.c -fno-caret-diagnostics
-fdiagnostics-add-output="sarif:file=msg.sarif"
gcc: error: unrecognized command-line option ‘-fno-caret-diagnostics’
% ls msg.sarif
ls: cannot access 'msg.sarif': No such file or directory