public inbox for [email protected]
help / color / mirror / Atom feedFrom: Thomas Munro <[email protected]>
To: Tom Lane <[email protected]>
Cc: pgsql-hackers <[email protected]>
Subject: Re: Tree-walker callbacks vs -Wdeprecated-non-prototype
Date: Mon, 12 Dec 2022 16:43:41 +1300
Message-ID: <CA+hUKGKtrz0S1NjAf=e76ZyvPi+JNvtJptgEdFFdtK7r4b2jnA@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CA+hUKGKpHPDTv67Y+s6yiC8KH5OXeDg6a-twWo_xznKTcG0kSA@mail.gmail.com>
<[email protected]>
<[email protected]>
<[email protected]>
<CA+hUKGK=xCw9_V7tCMvpT5D83AH8ArotTw3W4s70Vhqr7VgZkg@mail.gmail.com>
<CA+hUKG+FVo16ReJa5qWU84h4wpN7w32FG1PUWDcsgQviL-2QEA@mail.gmail.com>
<[email protected]>
<[email protected]>
<[email protected]>
<CA+hUKGJvX+L3aMN84ksT-cGy08VHErRNip3nV-WmTx7f6Pqhyw@mail.gmail.com>
<[email protected]>
On Mon, Dec 12, 2022 at 4:07 PM Tom Lane <[email protected]> wrote:
> Thomas Munro <[email protected]> writes:
> > As visible on seawasp and locally (16/main branch nightly packages),
> > they decided to start warning about these casts with a new strict
> > variant of the warning. Their discussion:
>
> > https://reviews.llvm.org/D134831
>
> > There are also a few other cases unrelated to this thread's original
> > problem, for example casts involving pg_funcptr_t, HashCompareFunc. I
> > guess our options would be to turn that warning off, or reconsider and
> > try shoving the cast of "generic" arguments pointers down into the
> > functions?
>
> I'm for "turn the warning off". Per previous discussion, adhering
> strictly to that rule would make our code worse (less legible AND
> less safe), not better.
Alright, this seems to do the trick here.
Attachments:
[text/x-patch] 0001-Disable-clang-16-s-Wcast-function-type-strict.patch (3.7K, ../CA+hUKGKtrz0S1NjAf=e76ZyvPi+JNvtJptgEdFFdtK7r4b2jnA@mail.gmail.com/2-0001-Disable-clang-16-s-Wcast-function-type-strict.patch)
download | inline diff:
From b01690ca859b5f27ece386577b7b9d9d7572b8d2 Mon Sep 17 00:00:00 2001
From: Thomas Munro <[email protected]>
Date: Mon, 12 Dec 2022 16:28:24 +1300
Subject: [PATCH] Disable clang 16's -Wcast-function-type-strict.
Clang 16 is still in development, but seawasp reveals that it has
started warning about many of our casts of function pointers. Disable
the new warning for now, since otherwise buildfarm animal seawasp fails.
May be back-patched with other Clang/LLVM 16 changes around release
time.
Discussion: https://postgr.es/m/CA%2BhUKGJvX%2BL3aMN84ksT-cGy08VHErRNip3nV-WmTx7f6Pqhyw%40mail.gmail.com
---
configure | 44 ++++++++++++++++++++++++++++++++++++++++++++
configure.ac | 6 ++++++
meson.build | 3 +++
3 files changed, 53 insertions(+)
diff --git a/configure b/configure
index 62f382c1d1..5025448a05 100755
--- a/configure
+++ b/configure
@@ -6611,6 +6611,50 @@ fi
if test -n "$NOT_THE_CFLAGS"; then
CFLAGS="$CFLAGS -Wno-stringop-truncation"
fi
+ # Suppress clang 16's strict warnings about function casts
+ NOT_THE_CFLAGS=""
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wcast-function-type-strict, for NOT_THE_CFLAGS" >&5
+$as_echo_n "checking whether ${CC} supports -Wcast-function-type-strict, for NOT_THE_CFLAGS... " >&6; }
+if ${pgac_cv_prog_CC_cflags__Wcast_function_type_strict+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ pgac_save_CFLAGS=$CFLAGS
+pgac_save_CC=$CC
+CC=${CC}
+CFLAGS="${NOT_THE_CFLAGS} -Wcast-function-type-strict"
+ac_save_c_werror_flag=$ac_c_werror_flag
+ac_c_werror_flag=yes
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ pgac_cv_prog_CC_cflags__Wcast_function_type_strict=yes
+else
+ pgac_cv_prog_CC_cflags__Wcast_function_type_strict=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_c_werror_flag=$ac_save_c_werror_flag
+CFLAGS="$pgac_save_CFLAGS"
+CC="$pgac_save_CC"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CC_cflags__Wcast_function_type_strict" >&5
+$as_echo "$pgac_cv_prog_CC_cflags__Wcast_function_type_strict" >&6; }
+if test x"$pgac_cv_prog_CC_cflags__Wcast_function_type_strict" = x"yes"; then
+ NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wcast-function-type-strict"
+fi
+
+
+ if test -n "$NOT_THE_CFLAGS"; then
+ CFLAGS="$CFLAGS -Wno-cast-function-type-strict"
+ fi
elif test "$ICC" = yes; then
# Intel's compiler has a bug/misoptimization in checking for
# division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.
diff --git a/configure.ac b/configure.ac
index cfb10f59ce..4cd328fc83 100644
--- a/configure.ac
+++ b/configure.ac
@@ -573,6 +573,12 @@ if test "$GCC" = yes -a "$ICC" = no; then
if test -n "$NOT_THE_CFLAGS"; then
CFLAGS="$CFLAGS -Wno-stringop-truncation"
fi
+ # Suppress clang 16's strict warnings about function casts
+ NOT_THE_CFLAGS=""
+ PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wcast-function-type-strict])
+ if test -n "$NOT_THE_CFLAGS"; then
+ CFLAGS="$CFLAGS -Wno-cast-function-type-strict"
+ fi
elif test "$ICC" = yes; then
# Intel's compiler has a bug/misoptimization in checking for
# division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.
diff --git a/meson.build b/meson.build
index a62d8171cc..9df8685dfd 100644
--- a/meson.build
+++ b/meson.build
@@ -1773,6 +1773,9 @@ negative_warning_flags = [
'format-truncation',
'stringop-truncation',
+ # Suppress clang 16's strict warnings about function casts
+ 'cast-function-type-strict',
+
# To make warning_level=2 / -Wextra work, we'd need at least the following
# 'clobbered',
# 'missing-field-initializers',
--
2.35.1
view thread (19+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Tree-walker callbacks vs -Wdeprecated-non-prototype
In-Reply-To: <CA+hUKGKtrz0S1NjAf=e76ZyvPi+JNvtJptgEdFFdtK7r4b2jnA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox