public inbox for [email protected]
help / color / mirror / Atom feedFrom: Peter Eisentraut <[email protected]>
To: Bertrand Drouvot <[email protected]>
Cc: [email protected]
Subject: Re: Enable -Wstrict-prototypes and -Wold-style-definition by default
Date: Fri, 27 Mar 2026 08:38:45 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <aa73q1aT0A3/vke/@ip-10-97-1-34.eu-west-3.compute.internal>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
The first three patches have been committed.
On 24.03.26 08:16, Bertrand Drouvot wrote:
> 0004:
>
> --- a/meson.build
> +++ b/meson.build
> @@ -2199,6 +2199,7 @@ unroll_loops_cflags = cc.get_supported_arguments(['-funroll-loops'])
>
> common_warning_flags = [
> '-Wmissing-prototypes',
> + '-Wold-style-declaration',
>
> Nit, what about adding it with (as the comment is also accurate for the new one)?
>
> "
> # These are C-only flags, supported in all C11-capable GCC/Clang versions.
> cflags_warn += cc.get_supported_arguments(['-Wstrict-prototypes', '-Wold-style-definition'])
> "
Yeah, makes sense to collect the C-only flags together. But now that
I'm looking at this again, the comment "supported in all C11-capable
GCC/Clang versions" is not relevant here, it was only relevant in
configure.ac because there we don't actually test for these flags but
require them without testing. What do you think about the attached
patch, which reorganizes this a bit more?
From ae3a34e762a7f8af22a0718f91d39200689c07e3 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Fri, 27 Mar 2026 08:34:37 +0100
Subject: [PATCH v3] Add warning option -Wold-style-declaration
This warning has been triggered a few times via the buildfarm (see
commits 8212625e53f, 2b7259f8557, afe86a9e73b), so we might as well
add it so that everyone sees it.
(This is completely separate from the recently added
-Wold-style-definition.)
Reviewed-by: Tom Lane <[email protected]>
Reviewed-by: Bertrand Drouvot <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/aa73q1aT0A3/vke/%40ip-10-97-1-34.eu-west-3.compute.intern...
---
configure | 41 +++++++++++++++++++++++++++++++++++++++++
configure.ac | 2 ++
meson.build | 14 +++++++++-----
3 files changed, 52 insertions(+), 5 deletions(-)
diff --git a/configure b/configure
index 8e0e7483c1d..d058605c7ad 100755
--- a/configure
+++ b/configure
@@ -5526,6 +5526,47 @@ fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wold-style-declaration, for CFLAGS" >&5
+$as_echo_n "checking whether ${CC} supports -Wold-style-declaration, for CFLAGS... " >&6; }
+if ${pgac_cv_prog_CC_cflags__Wold_style_declaration+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ pgac_save_CFLAGS=$CFLAGS
+pgac_save_CC=$CC
+CC=${CC}
+CFLAGS="${CFLAGS} -Wold-style-declaration"
+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__Wold_style_declaration=yes
+else
+ pgac_cv_prog_CC_cflags__Wold_style_declaration=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__Wold_style_declaration" >&5
+$as_echo "$pgac_cv_prog_CC_cflags__Wold_style_declaration" >&6; }
+if test x"$pgac_cv_prog_CC_cflags__Wold_style_declaration" = x"yes"; then
+ CFLAGS="${CFLAGS} -Wold-style-declaration"
+fi
+
+
+ # -Wold-style-declaration is not applicable for C++
+
# To require fallthrough attribute annotations, use
# -Wimplicit-fallthrough=5 with gcc and -Wimplicit-fallthrough with
# clang. The latter is also accepted on gcc but does not enforce
diff --git a/configure.ac b/configure.ac
index 2baac5e9da7..c27afee1822 100644
--- a/configure.ac
+++ b/configure.ac
@@ -555,6 +555,8 @@ if test "$GCC" = yes -a "$ICC" = no; then
PGAC_PROG_CXX_CFLAGS_OPT([-Werror=unguarded-availability-new])
PGAC_PROG_CC_CFLAGS_OPT([-Wmissing-format-attribute])
PGAC_PROG_CXX_CFLAGS_OPT([-Wmissing-format-attribute])
+ PGAC_PROG_CC_CFLAGS_OPT([-Wold-style-declaration])
+ # -Wold-style-declaration is not applicable for C++
# To require fallthrough attribute annotations, use
# -Wimplicit-fallthrough=5 with gcc and -Wimplicit-fallthrough with
diff --git a/meson.build b/meson.build
index ea31cbce9c0..0ee772cd475 100644
--- a/meson.build
+++ b/meson.build
@@ -2198,7 +2198,6 @@ vectorize_cflags = cc.get_supported_arguments(['-ftree-vectorize'])
unroll_loops_cflags = cc.get_supported_arguments(['-funroll-loops'])
common_warning_flags = [
- '-Wmissing-prototypes',
'-Wpointer-arith',
# Really don't want VLAs to be used in our dialect of C
'-Werror=vla',
@@ -2211,7 +2210,15 @@ common_warning_flags = [
'-Wformat-security',
]
-cflags_warn += cc.get_supported_arguments(common_warning_flags)
+# C-only warnings
+c_warning_flags = [
+ '-Wmissing-prototypes',
+ '-Wold-style-declaration',
+ '-Wold-style-definition',
+ '-Wstrict-prototypes',
+]
+
+cflags_warn += cc.get_supported_arguments(common_warning_flags, c_warning_flags)
if have_cxx
cxxflags_warn += cxx.get_supported_arguments(common_warning_flags)
endif
@@ -2252,9 +2259,6 @@ if cc.has_argument('-Wmissing-variable-declarations')
cflags_no_missing_var_decls += '-Wno-missing-variable-declarations'
endif
-# These are C-only flags, supported in all C11-capable GCC/Clang versions.
-cflags_warn += cc.get_supported_arguments(['-Wstrict-prototypes', '-Wold-style-definition'])
-
# The following tests want to suppress various unhelpful warnings by adding
# -Wno-foo switches. But gcc won't complain about unrecognized -Wno-foo
# switches, so we have to test for the positive form and if that works,
--
2.53.0
Attachments:
[text/plain] v3-0001-Add-warning-option-Wold-style-declaration.patch (4.4K, 2-v3-0001-Add-warning-option-Wold-style-declaration.patch)
download | inline diff:
From ae3a34e762a7f8af22a0718f91d39200689c07e3 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Fri, 27 Mar 2026 08:34:37 +0100
Subject: [PATCH v3] Add warning option -Wold-style-declaration
This warning has been triggered a few times via the buildfarm (see
commits 8212625e53f, 2b7259f8557, afe86a9e73b), so we might as well
add it so that everyone sees it.
(This is completely separate from the recently added
-Wold-style-definition.)
Reviewed-by: Tom Lane <[email protected]>
Reviewed-by: Bertrand Drouvot <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/aa73q1aT0A3/vke/%40ip-10-97-1-34.eu-west-3.compute.internal
---
configure | 41 +++++++++++++++++++++++++++++++++++++++++
configure.ac | 2 ++
meson.build | 14 +++++++++-----
3 files changed, 52 insertions(+), 5 deletions(-)
diff --git a/configure b/configure
index 8e0e7483c1d..d058605c7ad 100755
--- a/configure
+++ b/configure
@@ -5526,6 +5526,47 @@ fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wold-style-declaration, for CFLAGS" >&5
+$as_echo_n "checking whether ${CC} supports -Wold-style-declaration, for CFLAGS... " >&6; }
+if ${pgac_cv_prog_CC_cflags__Wold_style_declaration+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ pgac_save_CFLAGS=$CFLAGS
+pgac_save_CC=$CC
+CC=${CC}
+CFLAGS="${CFLAGS} -Wold-style-declaration"
+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__Wold_style_declaration=yes
+else
+ pgac_cv_prog_CC_cflags__Wold_style_declaration=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__Wold_style_declaration" >&5
+$as_echo "$pgac_cv_prog_CC_cflags__Wold_style_declaration" >&6; }
+if test x"$pgac_cv_prog_CC_cflags__Wold_style_declaration" = x"yes"; then
+ CFLAGS="${CFLAGS} -Wold-style-declaration"
+fi
+
+
+ # -Wold-style-declaration is not applicable for C++
+
# To require fallthrough attribute annotations, use
# -Wimplicit-fallthrough=5 with gcc and -Wimplicit-fallthrough with
# clang. The latter is also accepted on gcc but does not enforce
diff --git a/configure.ac b/configure.ac
index 2baac5e9da7..c27afee1822 100644
--- a/configure.ac
+++ b/configure.ac
@@ -555,6 +555,8 @@ if test "$GCC" = yes -a "$ICC" = no; then
PGAC_PROG_CXX_CFLAGS_OPT([-Werror=unguarded-availability-new])
PGAC_PROG_CC_CFLAGS_OPT([-Wmissing-format-attribute])
PGAC_PROG_CXX_CFLAGS_OPT([-Wmissing-format-attribute])
+ PGAC_PROG_CC_CFLAGS_OPT([-Wold-style-declaration])
+ # -Wold-style-declaration is not applicable for C++
# To require fallthrough attribute annotations, use
# -Wimplicit-fallthrough=5 with gcc and -Wimplicit-fallthrough with
diff --git a/meson.build b/meson.build
index ea31cbce9c0..0ee772cd475 100644
--- a/meson.build
+++ b/meson.build
@@ -2198,7 +2198,6 @@ vectorize_cflags = cc.get_supported_arguments(['-ftree-vectorize'])
unroll_loops_cflags = cc.get_supported_arguments(['-funroll-loops'])
common_warning_flags = [
- '-Wmissing-prototypes',
'-Wpointer-arith',
# Really don't want VLAs to be used in our dialect of C
'-Werror=vla',
@@ -2211,7 +2210,15 @@ common_warning_flags = [
'-Wformat-security',
]
-cflags_warn += cc.get_supported_arguments(common_warning_flags)
+# C-only warnings
+c_warning_flags = [
+ '-Wmissing-prototypes',
+ '-Wold-style-declaration',
+ '-Wold-style-definition',
+ '-Wstrict-prototypes',
+]
+
+cflags_warn += cc.get_supported_arguments(common_warning_flags, c_warning_flags)
if have_cxx
cxxflags_warn += cxx.get_supported_arguments(common_warning_flags)
endif
@@ -2252,9 +2259,6 @@ if cc.has_argument('-Wmissing-variable-declarations')
cflags_no_missing_var_decls += '-Wno-missing-variable-declarations'
endif
-# These are C-only flags, supported in all C11-capable GCC/Clang versions.
-cflags_warn += cc.get_supported_arguments(['-Wstrict-prototypes', '-Wold-style-definition'])
-
# The following tests want to suppress various unhelpful warnings by adding
# -Wno-foo switches. But gcc won't complain about unrecognized -Wno-foo
# switches, so we have to test for the positive form and if that works,
--
2.53.0
view thread (18+ 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], [email protected]
Subject: Re: Enable -Wstrict-prototypes and -Wold-style-definition by default
In-Reply-To: <[email protected]>
* 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