summaryrefslogtreecommitdiff
path: root/src/bin/pgbench/exprparse.y
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
commit2e124d857a64a91d2b70afdbed6156d753089771 (patch)
treef6f303985abd59954e6050417447f4b6717f67bf /src/bin/pgbench/exprparse.y
parent382cc68007784623e365ec033468ec69535afbaf (diff)
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/bin/pgbench/exprparse.y')
-rw-r--r--src/bin/pgbench/exprparse.y5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/bin/pgbench/exprparse.y b/src/bin/pgbench/exprparse.y
index 56f75ccd253..b3dd0488b2a 100644
--- a/src/bin/pgbench/exprparse.y
+++ b/src/bin/pgbench/exprparse.y
@@ -80,7 +80,10 @@ static PgBenchExpr *make_case(yyscan_t yyscanner, PgBenchExprList *when_then_lis
%%
-result: expr { expr_parse_result = $1; }
+result: expr {
+ expr_parse_result = $1;
+ (void) yynerrs; /* suppress compiler warning */
+ }
elist: { $$ = NULL; }
| expr { $$ = make_elist($1, NULL); }