Re: perl 5.36, C99, -Wdeclaration-after-statement -Wshadow=compatible-local - Mailing list pgsql-hackers

From Andres Freund
Subject Re: perl 5.36, C99, -Wdeclaration-after-statement -Wshadow=compatible-local
Date
Msg-id 20221228182455.hfdwd22zztvkojy2@awork3.anarazel.de
Whole thread Raw
In response to Re: perl 5.36, C99, -Wdeclaration-after-statement -Wshadow=compatible-local  (Andres Freund <andres@anarazel.de>)
Responses Re: perl 5.36, C99, -Wdeclaration-after-statement -Wshadow=compatible-local  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,

On 2022-11-02 17:03:34 -0700, Andres Freund wrote:
> On 2022-11-02 19:57:45 -0400, Tom Lane wrote:
> > Andres Freund <andres@anarazel.de> writes:
> > > On 2022-11-01 17:00:27 -0400, Peter Eisentraut wrote:
> > >> Python has the same issues.  There are a few other Python-embedding projects
> > >> that use -Wdeclaration-after-statement and complain if the Python headers
> > >> violate it.  But it's getting tedious.  -isystem would be a better solution.
> >
> > > Which dependencies should we convert to -isystem?
> >
> > Color me confused about what's being discussed here.  I see nothing
> > in the gcc manual suggesting that -isystem has any effect on warning
> > levels?
>
> It's only indirectly explained :(
>
>            The -isystem and -idirafter options also mark the directory as a system directory, so that it gets the
samespecial treatment that is applied to
 
>            the standard system directories.
>
> and then https://gcc.gnu.org/onlinedocs/cpp/System-Headers.html

The attached *prototype* patch is a slightly different spin on the idea of
using -isystem: It adds a
  #pragma GCC system_header
to plperl.h if supported by the compiler. That also avoids warnings from
within plperl and subsidiary headers.

I don't really have an opinion about whether using the pragma or -isystem is
preferrable. I chose the pragma because it makes it easier to grep for headers
where we chose to do this.


I added the pragma detection only to the meson build, but if others think this
is a good way to go, I'll do the necessary autoconf wrangling as well.


In the compiler test, I chose to not check whether -Werror=unknown-pragmas is
supported - it appears to be an old gcc flag, and the worst outcome is that
HAVE_PRAGMA_SYSTEM_HEADER isn't defined.

We could alternatively define HAVE_PRAGMA_SYSTEM_HEADER or such based on
__GNUC__ being defined.

Greetings,

Andres Freund

Attachment

pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: New strategies for freezing, advancing relfrozenxid early
Next
From: Tom Lane
Date:
Subject: Re: perl 5.36, C99, -Wdeclaration-after-statement -Wshadow=compatible-local