diff --git a/configure b/configure index 1d2522483a8..0d3f634abec 100755 --- a/configure +++ b/configure @@ -16986,6 +16986,14 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ fi +# These flags are supported in all C11-capable GCC/Clang versions, +# so no capability test is needed. Added here to avoid affecting configure probes, +# particularly PGAC_PRINTF_ARCHETYPE which uses -Werror and would fail to detect +# gnu_printf if -Wstrict-prototypes is active. +if test "$GCC" = yes -a "$ICC" = no; then + CFLAGS="$CFLAGS -Wstrict-prototypes -Wold-style-definition" +fi + # -------------------- # Run tests below here # -------------------- diff --git a/configure.ac b/configure.ac index 70ddcaabc44..f8327a7020a 100644 --- a/configure.ac +++ b/configure.ac @@ -2027,6 +2027,14 @@ related to locating shared libraries. Check the file 'config.log' for the exact reason.]])], [AC_MSG_RESULT([cross-compiling])]) +# These flags are supported in all C11-capable GCC/Clang versions, +# so no capability test is needed. Added here to avoid affecting configure probes, +# particularly PGAC_PRINTF_ARCHETYPE which uses -Werror and would fail to detect +# gnu_printf if -Wstrict-prototypes is active. +if test "$GCC" = yes -a "$ICC" = no; then + CFLAGS="$CFLAGS -Wstrict-prototypes -Wold-style-definition" +fi + # -------------------- # Run tests below here # -------------------- diff --git a/meson.build b/meson.build index c6e7cae5055..0a181909fab 100644 --- a/meson.build +++ b/meson.build @@ -2253,6 +2253,8 @@ 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 diff --git a/src/bin/psql/input.h b/src/bin/psql/input.h index 09961c84101..2a47166347e 100644 --- a/src/bin/psql/input.h +++ b/src/bin/psql/input.h @@ -17,6 +17,15 @@ #ifdef HAVE_LIBREADLINE #define USE_READLINE 1 +/* + * Readline headers trigger a lot of warnings with our preferred compiler flags + * (at least -Wstrict-prototypes is known to be problematic). The system_header + * pragma hides warnings from within the rest of this file, if supported. + */ +#ifdef HAVE_PRAGMA_GCC_SYSTEM_HEADER +#pragma GCC system_header +#endif + #if defined(HAVE_READLINE_READLINE_H) #include #if defined(HAVE_READLINE_HISTORY_H)