Re: [PATCH 0/6] Turn some C warnings into errors by default

2023-11-13 Thread Sam James


Florian Weimer  writes:

> This patch series converts the following warnings into errors by
> default:
>
>   -Wint-conversion
>   -Wimplicit-function-declaration
>   -Wimplicit-int
>   -Wreturn-mismatch
>   -Wincompatible-pointer-types
>
> As explained in the first commit, I decided not to use permerror_opt
> because it does not exhibit the existing behavior for -pedantic-errors.
>
> The impact on existing sources of the last commit is not really known to
> me at this point.  I plan to start a Fedora build later this week with
> an instrumented compiler, to see how much of a compatible impact it will
> be.  The first conversion pass through Fedora only covered
> -Wimplicit-function-declaration, -Wimplicit-int.  I started looking at
> -Wint-conversion, and it did not seem to be too bad, so I think
> including it should be fine.  I'm more worried about
> -Wincompatible-pointer-types.
>
> I have not yet added a new overview test for -fpermissive.  Such a test
> should trigger all the dozen or so places where I introduced
> pedpermerror, and see what happens under multiple dialects, each with
> -fpermissive and without, and maybe also with and withoyt for
> -pedantic-errors in -std=gnu89 and default modes.  I plan to do this
> once I get some initial feedback on the direction of these series
> because this test would likely be obsolete fairly quickly if changes to
> the diagnostics are required.  I did copy some existing tests to test
> both the error and warning (-fpermissive) diagnostics, and adjusted
> others to expect errors, so there is already quite a bit coverage
> without that overview test.
>
> Right now, this series breaks the build on aarch64-linux-gnu due to an
> incompatible pointer assignment in libgcc:
>
>   [PATCH] aarch64: Avoid -Wincompatible-pointer-types warning in Linux 
> unwinder
>   
> 
>
> Other targets had the same issue previously, but I've already fixed most
> of them (I hope).  There could of course be similar issues lurking in
> target-specific code, or even in system headers.
>
> With the recent testsuite fixes, the testsuite should be fairly clean
> despite these changes.  I verified that on i686-linux-gnu,
> powerpc64-linux-gnu, and x86_64-linux-gnu.  There is one
> aarch64-linux-gnu testsuite change I'd like the AArch64 maintainers to
> review:

I'll incrementally work on the other targets once stuff lands.

>
>   [PATCH] aarch64: Call named function in gcc.target/aarch64/aapcs64/ice_1.c
>   
> 
>
> Recently, I also found a problem in the gm2 testsuite:
>
>   [PATCH] gm2: Add missing declaration of m2pim_M2RTS_Terminate to test
>   
> 
>

Also, please tag PR96284 for all of these.

> Thanks,
> Florian
>
>
> Florian Weimer (6):
>   c-family: Introduce pedpermerror
>   c: Turn int-conversion warnings into permerrors
>   c: Turn -Wimplicit-function-declaration into a pedpermerror
>   c: Turn -Wimplicit-int into a pedpermerror
>   c: Turn -Wreturn-mismatch into a pedpermerror
>   c: Turn -Wincompatible-pointer-types into a pedpermerror
>
>  gcc/c-family/c-common.h   |   4 +
>  gcc/c-family/c-warn.cc|  34 
>  gcc/c/c-decl.cc   |  40 ++--
>  gcc/c/c-typeck.cc | 164 +--
>  gcc/diagnostic-core.h |   3 +
>  gcc/diagnostic.cc |   7 +
>  gcc/doc/invoke.texi   |  33 +++-
>  gcc/testsuite/c-c++-common/pr77624-1.c|   4 +-
>  .../c-c++-common/spellcheck-reserved.c|   4 +-
>  gcc/testsuite/gcc.dg/20030906-1.c |   2 +-
>  gcc/testsuite/gcc.dg/20030906-1a.c|  21 ++
>  gcc/testsuite/gcc.dg/20030906-2.c |   2 +-
>  gcc/testsuite/gcc.dg/20030906-2a.c|  21 ++
>  .../Wimplicit-function-declaration-c99-2.c|   7 +
>  .../Wimplicit-function-declaration-c99.c  |   2 +-
>  gcc/testsuite/gcc.dg/Wimplicit-int-1.c|   2 +-
>  gcc/testsuite/gcc.dg/Wimplicit-int-1a.c   |  11 ++
>  gcc/testsuite/gcc.dg/Wimplicit-int-4.c|   2 +-
>  gcc/testsuite/gcc.dg/Wimplicit-int-4a.c   |  11 ++
>  .../gcc.dg/Wincompatible-pointer-types-2.c|   2 +-
>  .../gcc.dg/Wincompatible-pointer-types-4.c|   2 +-
>  .../gcc.dg/Wincompatible-pointer-types-5.c|  10 +
>  .../gcc.dg/Wincompatible-pointer-types-6.c|  10 +
>  gcc/testsuite/gcc.dg/Wint-conversion-2.c  |   2 +-
>  gcc/testsuite/gcc.dg/Wint-conversion-3.c  |   2 +-
>  gcc/testsuite/gcc.dg/Wint-conversion-4.c  |  14 ++
>  gcc/testsuite/gcc.dg/Wreturn-mismatch-1.c |   2 +-
>  gcc/testsuite/gcc.dg/Wreturn-mismatch-1a.c|  40 
>  gcc/testsuite/gcc.dg/Wreturn-mismatch-2.c |   2 +-
>  

[PATCH 0/6] Turn some C warnings into errors by default

2023-11-13 Thread Florian Weimer
This patch series converts the following warnings into errors by
default:

  -Wint-conversion
  -Wimplicit-function-declaration
  -Wimplicit-int
  -Wreturn-mismatch
  -Wincompatible-pointer-types

As explained in the first commit, I decided not to use permerror_opt
because it does not exhibit the existing behavior for -pedantic-errors.

The impact on existing sources of the last commit is not really known to
me at this point.  I plan to start a Fedora build later this week with
an instrumented compiler, to see how much of a compatible impact it will
be.  The first conversion pass through Fedora only covered
-Wimplicit-function-declaration, -Wimplicit-int.  I started looking at
-Wint-conversion, and it did not seem to be too bad, so I think
including it should be fine.  I'm more worried about
-Wincompatible-pointer-types.

I have not yet added a new overview test for -fpermissive.  Such a test
should trigger all the dozen or so places where I introduced
pedpermerror, and see what happens under multiple dialects, each with
-fpermissive and without, and maybe also with and withoyt for
-pedantic-errors in -std=gnu89 and default modes.  I plan to do this
once I get some initial feedback on the direction of these series
because this test would likely be obsolete fairly quickly if changes to
the diagnostics are required.  I did copy some existing tests to test
both the error and warning (-fpermissive) diagnostics, and adjusted
others to expect errors, so there is already quite a bit coverage
without that overview test.

Right now, this series breaks the build on aarch64-linux-gnu due to an
incompatible pointer assignment in libgcc:

  [PATCH] aarch64: Avoid -Wincompatible-pointer-types warning in Linux unwinder
  


Other targets had the same issue previously, but I've already fixed most
of them (I hope).  There could of course be similar issues lurking in
target-specific code, or even in system headers.

With the recent testsuite fixes, the testsuite should be fairly clean
despite these changes.  I verified that on i686-linux-gnu,
powerpc64-linux-gnu, and x86_64-linux-gnu.  There is one
aarch64-linux-gnu testsuite change I'd like the AArch64 maintainers to
review:

  [PATCH] aarch64: Call named function in gcc.target/aarch64/aapcs64/ice_1.c
  


Recently, I also found a problem in the gm2 testsuite:

  [PATCH] gm2: Add missing declaration of m2pim_M2RTS_Terminate to test
  


Thanks,
Florian


Florian Weimer (6):
  c-family: Introduce pedpermerror
  c: Turn int-conversion warnings into permerrors
  c: Turn -Wimplicit-function-declaration into a pedpermerror
  c: Turn -Wimplicit-int into a pedpermerror
  c: Turn -Wreturn-mismatch into a pedpermerror
  c: Turn -Wincompatible-pointer-types into a pedpermerror

 gcc/c-family/c-common.h   |   4 +
 gcc/c-family/c-warn.cc|  34 
 gcc/c/c-decl.cc   |  40 ++--
 gcc/c/c-typeck.cc | 164 +--
 gcc/diagnostic-core.h |   3 +
 gcc/diagnostic.cc |   7 +
 gcc/doc/invoke.texi   |  33 +++-
 gcc/testsuite/c-c++-common/pr77624-1.c|   4 +-
 .../c-c++-common/spellcheck-reserved.c|   4 +-
 gcc/testsuite/gcc.dg/20030906-1.c |   2 +-
 gcc/testsuite/gcc.dg/20030906-1a.c|  21 ++
 gcc/testsuite/gcc.dg/20030906-2.c |   2 +-
 gcc/testsuite/gcc.dg/20030906-2a.c|  21 ++
 .../Wimplicit-function-declaration-c99-2.c|   7 +
 .../Wimplicit-function-declaration-c99.c  |   2 +-
 gcc/testsuite/gcc.dg/Wimplicit-int-1.c|   2 +-
 gcc/testsuite/gcc.dg/Wimplicit-int-1a.c   |  11 ++
 gcc/testsuite/gcc.dg/Wimplicit-int-4.c|   2 +-
 gcc/testsuite/gcc.dg/Wimplicit-int-4a.c   |  11 ++
 .../gcc.dg/Wincompatible-pointer-types-2.c|   2 +-
 .../gcc.dg/Wincompatible-pointer-types-4.c|   2 +-
 .../gcc.dg/Wincompatible-pointer-types-5.c|  10 +
 .../gcc.dg/Wincompatible-pointer-types-6.c|  10 +
 gcc/testsuite/gcc.dg/Wint-conversion-2.c  |   2 +-
 gcc/testsuite/gcc.dg/Wint-conversion-3.c  |   2 +-
 gcc/testsuite/gcc.dg/Wint-conversion-4.c  |  14 ++
 gcc/testsuite/gcc.dg/Wreturn-mismatch-1.c |   2 +-
 gcc/testsuite/gcc.dg/Wreturn-mismatch-1a.c|  40 
 gcc/testsuite/gcc.dg/Wreturn-mismatch-2.c |   2 +-
 gcc/testsuite/gcc.dg/Wreturn-mismatch-2a.c|  41 
 gcc/testsuite/gcc.dg/anon-struct-11.c |   5 +-
 gcc/testsuite/gcc.dg/anon-struct-11a.c| 111 +++
 gcc/testsuite/gcc.dg/anon-struct-13.c |   2 +-
 gcc/testsuite/gcc.dg/anon-struct-13a.c|  76 +++
 gcc/testsuite/gcc.dg/assign-warn-1.c  |   2 +-