aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-09-20 12:04:37 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2022-09-20 12:04:37 -0400
commitf38a0bde21776f6a8e92b73645c3d54764c85459 (patch)
treec01900cb3c50c412ebe0451f8802aad5f884d552 /src/backend/utils/adt
parentadc26e0e88b318454f7962eb0c26aa07a459ee1a (diff)
downloadpostgresql-f38a0bde21776f6a8e92b73645c3d54764c85459.tar.gz
postgresql-f38a0bde21776f6a8e92b73645c3d54764c85459.zip
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
Diffstat (limited to 'src/backend/utils/adt')
-rw-r--r--src/backend/utils/adt/array_typanalyze.c4
-rw-r--r--src/backend/utils/adt/jsonpath_gram.y1
2 files changed, 2 insertions, 3 deletions
diff --git a/src/backend/utils/adt/array_typanalyze.c b/src/backend/utils/adt/array_typanalyze.c
index eafb94b697e..f8fd6cb8cb5 100644
--- a/src/backend/utils/adt/array_typanalyze.c
+++ b/src/backend/utils/adt/array_typanalyze.c
@@ -218,7 +218,6 @@ compute_array_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
{
ArrayAnalyzeExtraData *extra_data;
int num_mcelem;
- int null_cnt = 0;
int null_elem_cnt = 0;
int analyzed_rows = 0;
@@ -322,8 +321,7 @@ compute_array_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
value = fetchfunc(stats, array_no, &isnull);
if (isnull)
{
- /* array is null, just count that */
- null_cnt++;
+ /* ignore arrays that are null overall */
continue;
}
diff --git a/src/backend/utils/adt/jsonpath_gram.y b/src/backend/utils/adt/jsonpath_gram.y
index 99a995d0b1c..7ecbd918595 100644
--- a/src/backend/utils/adt/jsonpath_gram.y
+++ b/src/backend/utils/adt/jsonpath_gram.y
@@ -128,6 +128,7 @@ result:
*result = palloc(sizeof(JsonPathParseResult));
(*result)->expr = $2;
(*result)->lax = $1;
+ (void) yynerrs;
}
| /* EMPTY */ { *result = NULL; }
;