Hello,

On Wed, Jun 25 2025, Steve Kargl wrote:
> Thanks for cleaning up gfortran code.  I was curious about
> what the GNU Coding Standard said about this case, but it
> does not consider initialization of subobjects.  I did find
>
>    5.3 Clean Use of C Constructs
>    ...
>    Don't make the program ugly just to placate static
>    analysis tools such as lint, clang, and GCC with extra
>    warnings options such as -Wconversion and -Wundef.
>    These tools can help find bugs and unclear code, but
>    they can also generate so many false alarms that it hurts
>    readability to silence them with unnecessary casts,
>    wrappers, and other complications.
>
> I do not see the extra '{...}' as hurting readability.  I
> have no objection to the change.  Does anyone else have a
> comment?

OK, I took that as an approval and committed the change as 0b7c27325c7.

Generally speaking, I agree that we definitely should not alter the
source code because of all clang warnings and we don't, we filter out
quite many of them in contrib/filter-clang-warnings.py.

But there is also benefit in limiting the number of cases we filter out
and in this case I thought it was easier to change the source code.

Thank you,

Martin


>
> -- 
> steve
>
>
> On Wed, Jun 25, 2025 at 04:18:16PM +0200, Martin Jambor wrote:
>> Hi,
>> 
>> when GCC is built with clang, it suggests that we add a brace to the
>> initialization of format_asterisk:
>> 
>>   gcc/fortran/io.cc:32:16: warning: suggest braces around initialization of 
>> subobject [-Wmissing-braces]
>> 
>> So this patch does that to silence it.
>> 
>> Bootstrapped and tested on x86_64-linx.  OK for master?
>> 
>> Alternatively, as with all of these clang warning issues, I'm
>> perfectly happy to add an entry to contrib/filter-clang-warnings.py to
>> ignore the warning instead.
>> 
>> Thanks,
>> 
>> Martin
>> 
>> 
>> 
>> gcc/fortran/ChangeLog:
>> 
>> 2025-06-24  Martin Jambor  <mjam...@suse.cz>
>> 
>>      * io.cc (format_asterisk): Add a brace around static initialization
>>      location part of the field locus.
>> ---
>>  gcc/fortran/io.cc | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/gcc/fortran/io.cc b/gcc/fortran/io.cc
>> index 7466d8fe094..4d28c2c90ba 100644
>> --- a/gcc/fortran/io.cc
>> +++ b/gcc/fortran/io.cc
>> @@ -29,7 +29,7 @@ along with GCC; see the file COPYING3.  If not see
>>  
>>  gfc_st_label
>>  format_asterisk = {0, NULL, NULL, -1, ST_LABEL_FORMAT, ST_LABEL_FORMAT, 
>> NULL,
>> -               0, {NULL, NULL}, NULL, 0};
>> +               0, {NULL, {NULL}}, NULL, 0};
>>  
>>  typedef struct
>>  {
>> -- 
>> 2.49.0
>
> -- 
> Steve

Reply via email to