Bug 96032 - RFE: add a way to use output from --fdiagnostics-format=json or sarif as input
Summary: RFE: add a way to use output from --fdiagnostics-format=json or sarif as input
Status: REOPENED
Alias: None
Product: gcc
Classification: Unclassified
Component: other (show other bugs)
Version: unknown
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL: https://gcc.gnu.org/pipermail/gcc-pat...
Keywords: diagnostic, patch, SARIF
Depends on:
Blocks:
 
Reported: 2020-07-02 12:55 UTC by Christian Friedl
Modified: 2024-06-26 10:58 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-08-24 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Friedl 2020-07-02 12:55:30 UTC
I would like to implement a filter for warnings from gfortran using --fdiagnostics-format=json . To print out the warnings in the way gfortran does normally I would need a way to convert them to text which should be the same as what --fdiagnostics-format=json produces. Since gfortran itself knows best how to print its warnings - could you provide that functionality?
Comment 1 Christian Friedl 2020-07-02 13:00:48 UTC
Disclaimer: I posted a request for help regarding this exact feature on the gcc-help list. (https://gcc.gnu.org/pipermail/gcc-help/2020-July/139110.html)

After reading through the list I came to the conclusion that this is not implemented and probably a feature request would be more appropriate.
Comment 2 Andrew Pinski 2021-08-24 09:50:03 UTC
Fixed in GCC 9 with r9-4156.  See PR 19165 too.

*** This bug has been marked as a duplicate of bug 19165 ***
Comment 3 David Malcolm 2021-08-24 13:09:03 UTC
(In reply to Andrew Pinski from comment #2)
> Fixed in GCC 9 with r9-4156.  See PR 19165 too.
> 
> *** This bug has been marked as a duplicate of bug 19165 ***

Bug 19165 covers adding JSON *output*; what this bug is asking for is a way to read in JSON as input, and instead generate the usual textual output (or, indeed other output formats).  Ideally we'd be able to "round trip" the diagnostic data through JSON.

Reopening; it seems like a useful thing for GCC to be able to do. Similarly, it would be good to be able to use SARIF as an input format (and output format), and ideally roundtrip through SARIF - but that's another RFE.
Comment 4 David Malcolm 2022-07-08 18:30:38 UTC
I posted a prototype implementation of this here:
  "[PATCH 00/12] RFC: Replay of serialized diagnostics"
    https://gcc.gnu.org/pipermail/gcc-patches/2022-June/597051.html

(doesn't fully work; see the many caveats in that post)