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 <tgl@sss.pgh.pa.us>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/aa73q1aT0A3/vke/%40ip-10-97-1-34.eu-west-3.compute.internal
+{ $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
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
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',
'-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
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,