pgsql: Suppress variable-set-but-not-used warnings from clang 15.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Suppress variable-set-but-not-used warnings from clang 15.
Date: 2022-09-20 16:05:10
Message-ID: E1oafkD-001DRd-Sb@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Suppress variable-set-but-not-used warnings from clang 15.

clang 15+ will issue a set-but-not-used warning when the only
use of a variable is in autoincrements (e.g., "foo++;").
That's perfectly sensible, but it detects a few more cases that
we'd not noticed before. Silence the warnings with our usual
methods, such as PG_USED_FOR_ASSERTS_ONLY, or in one case by
actually removing a useless variable.

One thing that we can't nicely get rid of is that with %pure-parser,
Bison emits "yynerrs" as a local variable that falls foul of this
warning. To silence those, I inserted "(void) yynerrs;" in the
top-level productions of affected grammars.

Per recently-established project policy, this is a candidate
for back-patching into out-of-support branches: it suppresses
annoying compiler warnings but changes no behavior. Hence,
back-patch to 9.5, which is as far as these patches go without
issues. (A preliminary check shows that the prior branches
need some other set-but-not-used cleanups too, so I'll leave
them for another day.)

Discussion: https://postgr.es/m/514615.1663615243@sss.pgh.pa.us

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/ca3b730baa1354c86bff78c246415443d4732f02

Modified Files
--------------
src/backend/access/gist/gistxlog.c | 2 +-
src/backend/access/transam/xlog.c | 2 +-
src/backend/parser/gram.y | 1 +
src/backend/utils/adt/array_typanalyze.c | 4 +---
src/backend/utils/adt/jsonpath_gram.y | 1 +
src/bin/pgbench/exprparse.y | 5 ++++-
6 files changed, 9 insertions(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2022-09-20 17:05:12 pgsql: Fix `trap` in a few shell scripts
Previous Message Alvaro Herrera 2022-09-20 10:39:39 pgsql: Disable autovacuum in MERGE test script