While working on the -Wdeprecated-non-prototype fixups discussed nearby, I saw that clang 15.0 produces a few other new warnings (which are also visible in the buildfarm). Pursuant to our usual policy that we should suppress warnings on compilers likely to be used for development, here's a patch to silence them.
There are three groups of these: * With %pure-parser, Bison makes the "yynerrs" variable local instead of static, and then if you don't use it clang notices that it's set but never read. There doesn't seem to be a way to persuade Bison not to emit the variable at all, so here I've just added "(void) yynerrs;" to the topmost production of each affected grammar. If anyone has a nicer idea, let's hear it. * xlog.c's AdvanceXLInsertBuffer has a local variable "npages" that is only read in the "#ifdef WAL_DEBUG" stanza at the bottom. Here I've done the rather ugly and brute-force thing of wrapping all the variable's references in "#ifdef WAL_DEBUG". (I tried marking it PG_USED_FOR_ASSERTS_ONLY, but oddly that did not silence the warning.) I kind of wonder how useful this function's WAL_DEBUG output is --- maybe just dropping that altogether would be better? * array_typanalyze.c's compute_array_stats counts the number of null arrays in the column, but then does nothing with the result. AFAICS this is redundant with what std_compute_stats will do, so I just removed the variable. Any thoughts? regards, tom lane
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 81d339d57d..2651bcaa76 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -1785,7 +1785,9 @@ AdvanceXLInsertBuffer(XLogRecPtr upto, TimeLineID tli, bool opportunistic) XLogRecPtr NewPageEndPtr = InvalidXLogRecPtr; XLogRecPtr NewPageBeginPtr; XLogPageHeader NewPage; +#ifdef WAL_DEBUG int npages = 0; +#endif LWLockAcquire(WALBufMappingLock, LW_EXCLUSIVE); @@ -1928,7 +1930,9 @@ AdvanceXLInsertBuffer(XLogRecPtr upto, TimeLineID tli, bool opportunistic) XLogCtl->InitializedUpTo = NewPageEndPtr; +#ifdef WAL_DEBUG npages++; +#endif } LWLockRelease(WALBufMappingLock); diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 82f03fc9c9..c6ec694ceb 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -864,6 +864,7 @@ parse_toplevel: stmtmulti { pg_yyget_extra(yyscanner)->parsetree = $1; + (void) yynerrs; /* suppress compiler warning */ } | MODE_TYPE_NAME Typename { diff --git a/src/backend/utils/adt/array_typanalyze.c b/src/backend/utils/adt/array_typanalyze.c index 1964cedd93..2360c680ac 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; @@ -320,8 +319,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 7e28853a57..2a56629cc3 100644 --- a/src/backend/utils/adt/jsonpath_gram.y +++ b/src/backend/utils/adt/jsonpath_gram.y @@ -113,6 +113,7 @@ result: *result = palloc(sizeof(JsonPathParseResult)); (*result)->expr = $2; (*result)->lax = $1; + (void) yynerrs; } | /* EMPTY */ { *result = NULL; } ; diff --git a/src/bin/pgbench/exprparse.y b/src/bin/pgbench/exprparse.y index ade2ecdaab..f6387d4a3c 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); }