Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oaMK8-0007PM-9t for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Sep 2022 19:20:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oaMK5-0002WG-L9 for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Sep 2022 19:20:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oaMK5-0002W7-BU for pgsql-hackers@lists.postgresql.org; Mon, 19 Sep 2022 19:20:53 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oaMJx-00009c-8x for pgsql-hackers@lists.postgresql.org; Mon, 19 Sep 2022 19:20:50 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 28JJKhTh514616 for ; Mon, 19 Sep 2022 15:20:43 -0400 From: Tom Lane To: pgsql-hackers@lists.postgresql.org Subject: Silencing the remaining clang 15 warnings MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <514478.1663615156.0@sss.pgh.pa.us> Date: Mon, 19 Sep 2022 15:20:43 -0400 Message-ID: <514615.1663615243@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <514478.1663615156.1@sss.pgh.pa.us> 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 ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="silence-clang-15-warnings.patch"; charset="us-ascii" Content-ID: <514478.1663615156.2@sss.pgh.pa.us> Content-Description: silence-clang-15-warnings.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transa= m/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 tl= i, bool opportunistic) XLogRecPtr NewPageEndPtr =3D InvalidXLogRecPtr; XLogRecPtr NewPageBeginPtr; XLogPageHeader NewPage; +#ifdef WAL_DEBUG int npages =3D 0; +#endif = LWLockAcquire(WALBufMappingLock, LW_EXCLUSIVE); = @@ -1928,7 +1930,9 @@ AdvanceXLInsertBuffer(XLogRecPtr upto, TimeLineID tl= i, bool opportunistic) = XLogCtl->InitializedUpTo =3D 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 =3D $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, AnalyzeAttrFe= tchFunc fetchfunc, { ArrayAnalyzeExtraData *extra_data; int num_mcelem; - int null_cnt =3D 0; int null_elem_cnt =3D 0; int analyzed_rows =3D 0; = @@ -320,8 +319,7 @@ compute_array_stats(VacAttrStats *stats, AnalyzeAttrFe= tchFunc fetchfunc, value =3D 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 =3D palloc(sizeof(JsonPathParseResult)); (*result)->expr =3D $2; (*result)->lax =3D $1; + (void) yynerrs; } | /* EMPTY */ { *result =3D 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, PgBen= chExprList *when_then_lis = %% = -result: expr { expr_parse_result =3D $1; } +result: expr { + expr_parse_result =3D $1; + (void) yynerrs; /* suppress compiler warning */ + } = elist: { $$ =3D NULL; } | expr { $$ =3D make_elist($1, NULL); } ------- =_aaaaaaaaaa0--