v2-0004-Add-warning-option-Wold-style-declaration.patch

text/plain

Filename: v2-0004-Add-warning-option-Wold-style-declaration.patch
Type: text/plain
Part: 3
Message: Re: Enable -Wstrict-prototypes and -Wold-style-definition by default

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v2-0004
Subject: Add warning option -Wold-style-declaration
File+
configure 41 0
configure.ac 2 0
meson.build 1 0
From 0ca80851beaf81a3f661b19f61df7fff81780ce7 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Mon, 23 Mar 2026 16:04:02 +0100
Subject: [PATCH v2 4/4] Add warning option -Wold-style-declaration

---
 configure    | 41 +++++++++++++++++++++++++++++++++++++++++
 configure.ac |  2 ++
 meson.build  |  1 +
 3 files changed, 44 insertions(+)

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 ec9188af49e..b4428760676 100644
--- 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',
   '-Wpointer-arith',
   # Really don't want VLAs to be used in our dialect of C
   '-Werror=vla',
-- 
2.53.0