diagnostics: fix crash with -fdiagnostics-format=json-file
Checks
Commit Message
Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
Ready to be installed?
Thanks,
Martin
PR middle-end/106133
gcc/ChangeLog:
* diagnostic.cc (diagnostic_output_format_init): If
-fdiagnostics-format=json-file and -E is used, then
base_file_name is null and we should not emit anything.
---
gcc/diagnostic.cc | 3 +++
1 file changed, 3 insertions(+)
Comments
On Fri, 2023-01-06 at 12:33 +0100, Martin Liška wrote:
> Patch can bootstrap on x86_64-linux-gnu and survives regression
> tests.
Thanks for the patch.
I noticed that you marked PR 108307 as a dup of this, which covers
-fdiagnostics-format=sarif-file (and a .S file as input).
The patch doesn't add any test coverage (for either of the diagnostic
formats).
If we try to emit a diagnostic and base_file_name is NULL, and the user
requested one of -fdiagnostics-format={json,sarif}-file, where do the
diagnostics go? Where should they go?
Dave
>
> Ready to be installed?
> Thanks,
> Martin
>
> PR middle-end/106133
>
> gcc/ChangeLog:
>
> * diagnostic.cc (diagnostic_output_format_init): If
> -fdiagnostics-format=json-file and -E is used, then
> base_file_name is null and we should not emit anything.
> ---
> gcc/diagnostic.cc | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc
> index c90c14e993e..fe7d121e340 100644
> --- a/gcc/diagnostic.cc
> +++ b/gcc/diagnostic.cc
> @@ -2277,6 +2277,9 @@ diagnostic_output_format_init
> (diagnostic_context *context,
> const char *base_file_name,
> enum diagnostics_output_format format)
> {
> + if (base_file_name == NULL)
> + return;
> +
> switch (format)
> {
> default:
On 1/6/23 14:21, David Malcolm wrote:
> On Fri, 2023-01-06 at 12:33 +0100, Martin Liška wrote:
>> Patch can bootstrap on x86_64-linux-gnu and survives regression
>> tests.
>
> Thanks for the patch.
>
> I noticed that you marked PR 108307 as a dup of this, which covers
> -fdiagnostics-format=sarif-file (and a .S file as input).
>
> The patch doesn't add any test coverage (for either of the diagnostic
> formats).
>
> If we try to emit a diagnostic and base_file_name is NULL, and the user
> requested one of -fdiagnostics-format={json,sarif}-file, where do the
> diagnostics go? Where should they go?
Hey.
I've done a new version of the patch where I utilize x_main_input_basename.
Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
Ready to be installed?
Thanks,
Martin
PING^1
On 1/10/23 16:10, Martin Liška wrote:
> On 1/6/23 14:21, David Malcolm wrote:
>> On Fri, 2023-01-06 at 12:33 +0100, Martin Liška wrote:
>>> Patch can bootstrap on x86_64-linux-gnu and survives regression
>>> tests.
>>
>> Thanks for the patch.
>>
>> I noticed that you marked PR 108307 as a dup of this, which covers
>> -fdiagnostics-format=sarif-file (and a .S file as input).
>>
>> The patch doesn't add any test coverage (for either of the diagnostic
>> formats).
>>
>> If we try to emit a diagnostic and base_file_name is NULL, and the user
>> requested one of -fdiagnostics-format={json,sarif}-file, where do the
>> diagnostics go? Where should they go?
>
> Hey.
>
> I've done a new version of the patch where I utilize x_main_input_basename.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?
> Thanks,
> Martin
PING^2
On 1/24/23 14:34, Martin Liška wrote:
> PING^1
>
> On 1/10/23 16:10, Martin Liška wrote:
>> On 1/6/23 14:21, David Malcolm wrote:
>>> On Fri, 2023-01-06 at 12:33 +0100, Martin Liška wrote:
>>>> Patch can bootstrap on x86_64-linux-gnu and survives regression
>>>> tests.
>>>
>>> Thanks for the patch.
>>>
>>> I noticed that you marked PR 108307 as a dup of this, which covers
>>> -fdiagnostics-format=sarif-file (and a .S file as input).
>>>
>>> The patch doesn't add any test coverage (for either of the diagnostic
>>> formats).
>>>
>>> If we try to emit a diagnostic and base_file_name is NULL, and the user
>>> requested one of -fdiagnostics-format={json,sarif}-file, where do the
>>> diagnostics go? Where should they go?
>>
>> Hey.
>>
>> I've done a new version of the patch where I utilize x_main_input_basename.
>>
>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>>
>> Ready to be installed?
>> Thanks,
>> Martin
>
PING^3
On 2/1/23 14:13, Martin Liška wrote:
> PING^2
>
> On 1/24/23 14:34, Martin Liška wrote:
>> PING^1
>>
>> On 1/10/23 16:10, Martin Liška wrote:
>>> On 1/6/23 14:21, David Malcolm wrote:
>>>> On Fri, 2023-01-06 at 12:33 +0100, Martin Liška wrote:
>>>>> Patch can bootstrap on x86_64-linux-gnu and survives regression
>>>>> tests.
>>>>
>>>> Thanks for the patch.
>>>>
>>>> I noticed that you marked PR 108307 as a dup of this, which covers
>>>> -fdiagnostics-format=sarif-file (and a .S file as input).
>>>>
>>>> The patch doesn't add any test coverage (for either of the diagnostic
>>>> formats).
>>>>
>>>> If we try to emit a diagnostic and base_file_name is NULL, and the user
>>>> requested one of -fdiagnostics-format={json,sarif}-file, where do the
>>>> diagnostics go? Where should they go?
>>>
>>> Hey.
>>>
>>> I've done a new version of the patch where I utilize x_main_input_basename.
>>>
>>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>>>
>>> Ready to be installed?
>>> Thanks,
>>> Martin
>>
>
PING^4
On 2/17/23 15:52, Martin Liška wrote:
> PING^3
>
> On 2/1/23 14:13, Martin Liška wrote:
>> PING^2
>>
>> On 1/24/23 14:34, Martin Liška wrote:
>>> PING^1
>>>
>>> On 1/10/23 16:10, Martin Liška wrote:
>>>> On 1/6/23 14:21, David Malcolm wrote:
>>>>> On Fri, 2023-01-06 at 12:33 +0100, Martin Liška wrote:
>>>>>> Patch can bootstrap on x86_64-linux-gnu and survives regression
>>>>>> tests.
>>>>>
>>>>> Thanks for the patch.
>>>>>
>>>>> I noticed that you marked PR 108307 as a dup of this, which covers
>>>>> -fdiagnostics-format=sarif-file (and a .S file as input).
>>>>>
>>>>> The patch doesn't add any test coverage (for either of the diagnostic
>>>>> formats).
>>>>>
>>>>> If we try to emit a diagnostic and base_file_name is NULL, and the user
>>>>> requested one of -fdiagnostics-format={json,sarif}-file, where do the
>>>>> diagnostics go? Where should they go?
>>>>
>>>> Hey.
>>>>
>>>> I've done a new version of the patch where I utilize x_main_input_basename.
>>>>
>>>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>>>>
>>>> Ready to be installed?
>>>> Thanks,
>>>> Martin
>>>
>>
>
PING^5
On 2/27/23 10:49, Martin Liška wrote:
> PING^4
>
> On 2/17/23 15:52, Martin Liška wrote:
>> PING^3
>>
>> On 2/1/23 14:13, Martin Liška wrote:
>>> PING^2
>>>
>>> On 1/24/23 14:34, Martin Liška wrote:
>>>> PING^1
>>>>
>>>> On 1/10/23 16:10, Martin Liška wrote:
>>>>> On 1/6/23 14:21, David Malcolm wrote:
>>>>>> On Fri, 2023-01-06 at 12:33 +0100, Martin Liška wrote:
>>>>>>> Patch can bootstrap on x86_64-linux-gnu and survives regression
>>>>>>> tests.
>>>>>>
>>>>>> Thanks for the patch.
>>>>>>
>>>>>> I noticed that you marked PR 108307 as a dup of this, which covers
>>>>>> -fdiagnostics-format=sarif-file (and a .S file as input).
>>>>>>
>>>>>> The patch doesn't add any test coverage (for either of the diagnostic
>>>>>> formats).
>>>>>>
>>>>>> If we try to emit a diagnostic and base_file_name is NULL, and the user
>>>>>> requested one of -fdiagnostics-format={json,sarif}-file, where do the
>>>>>> diagnostics go? Where should they go?
>>>>>
>>>>> Hey.
>>>>>
>>>>> I've done a new version of the patch where I utilize x_main_input_basename.
>>>>>
>>>>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>>>>>
>>>>> Ready to be installed?
>>>>> Thanks,
>>>>> Martin
>>>>
>>>
>>
>
On Tue, 2023-01-10 at 16:10 +0100, Martin Liška wrote:
> On 1/6/23 14:21, David Malcolm wrote:
> > On Fri, 2023-01-06 at 12:33 +0100, Martin Liška wrote:
> > > Patch can bootstrap on x86_64-linux-gnu and survives regression
> > > tests.
> >
> > Thanks for the patch.
> >
> > I noticed that you marked PR 108307 as a dup of this, which covers
> > -fdiagnostics-format=sarif-file (and a .S file as input).
> >
> > The patch doesn't add any test coverage (for either of the
> > diagnostic
> > formats).
> >
> > If we try to emit a diagnostic and base_file_name is NULL, and the
> > user
> > requested one of -fdiagnostics-format={json,sarif}-file, where do
> > the
> > diagnostics go? Where should they go?
>
> Hey.
>
> I've done a new version of the patch where I utilize
> x_main_input_basename.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression
> tests.
>
> Ready to be installed?
Sorry about the long delay; the updated patch is good for trunk.
Thanks
Dave
@@ -2277,6 +2277,9 @@ diagnostic_output_format_init (diagnostic_context *context,
const char *base_file_name,
enum diagnostics_output_format format)
{
+ if (base_file_name == NULL)
+ return;
+
switch (format)
{
default: