Re: Should we remove -Wdeclaration-after-statement?

From: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, "ranier(dot)vf(at)gmail(dot)com" <ranier(dot)vf(at)gmail(dot)com>, chap(at)anastigmatix(dot)net
Subject: Re: Should we remove -Wdeclaration-after-statement?
Date: 2023-12-27 17:59:47
Message-ID: CAGECzQQwu9iyq--0jjRtVT39AhWDbUqwF6k3nc=TkzPyKSVNYw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 27 Dec 2023 at 16:05, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> This has already been debated, and the conclusion was that we would
> stick to the existing style for consistency reasons.

I looked through the archives quite a bit, but I couldn't find any
conclusive debate about the current declaration style. Definitely not
one with "consistency reasons" as being the conclusion. Could you
point me to the place where that conclusion was reached? Or could you
at least clarify what consistency you believe is lost by removing the
warning? The threads discussing this warning that I did find were the
following:

The initial addition of the warning flag[1], which has very little discussion.

Introducing the C99 requirement[2]. Robert and you both preferred the
current declaration style. Andrew and Andres both would want to accept
the new declaration style.

Another where removal of this warning was suggested[3], and where
Andres said he was in favor of removing the warning. But he didn't
think fighting for it was worth the effort at the time to fight you
and Robert, when he was trying to get the general C99 requirement in.

And finally, one that was started by me, where I suggest an automated
refactor[4]. This change got shot down because it would cause lots of
backpatching problems (and because it was using perl regexes instead
of an AST parser to do the automated refactor). Ranier and you were
proponents of the current declaration style. Chapman was in favor of
the new declaration style. Andrew seems neutral.

P.S. Note, that I'm not suggesting a complete refactor this time. I'm
only proposing to relax the rules, and disable the warning, so newly
written code can benefit. But if the only reason not to remove the
warning is that then there would be two styles of declaration in the
codebase, then I'm happy to create another refactoring script that
moves declarations down to their first usage. (Which could then be run
on all backbranches to make sure there is no backpatching pain)

[1]: https://www.postgresql.org/message-id/flat/417263F8.4060102%40samurai.com
[2]: https://www.postgresql.org/message-id/flat/CA%2BTgmoYvHzFkwChsamwbBrLNJRcRq%2BfyTwveFaN_YOWUsRnfpw%40mail.gmail.com#931f4c68237caf4c60b4dc298236aef1
[3]: https://www.postgresql.org/message-id/flat/20181213210012.i7iihamlbi7vfdiw%40alap3.anarazel.de#00304f9dfc039da87383fed30be62cff
[4]: https://www.postgresql.org/message-id/flat/AM5PR83MB0178E68E4FF1BAF9C66DF0D1F7C09%40AM5PR83MB0178.EURPRD83.prod.outlook.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tristan Partin 2023-12-27 18:20:22 Re: Add support for __attribute__((returns_nonnull))
Previous Message Tom Lane 2023-12-27 17:38:41 Re: postgres_fdw fails to see that array type belongs to extension