summaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorPeter Eisentraut2024-08-03 09:42:37 +0000
committerPeter Eisentraut2024-08-03 09:51:02 +0000
commit66188912566b5614dff095ae86f4b1e06d58e875 (patch)
tree3c86ba7c2b967437b29f83eb49231f43577ac023 /configure
parent7926a9a80f6daf0fcc1feb1bee5c51fd001bc173 (diff)
Add -Wmissing-variable-declarations to the standard compilation flags
This warning flag detects global variables not declared in header files. This is similar to what -Wmissing-prototypes does for functions. (More correctly, it is similar to what -Wmissing-declarations does for functions, but -Wmissing-prototypes is a superset of that in C.) This flag is new in GCC 14. Clang has supported it for a while. Several recent commits have cleaned up warnings triggered by this, so it should now be clean. Reviewed-by: Andres Freund <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/[email protected]
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure49
1 files changed, 49 insertions, 0 deletions
diff --git a/configure b/configure
index 79161e581b7..4f3aa447566 100755
--- a/configure
+++ b/configure
@@ -741,6 +741,7 @@ CXXFLAGS_SL_MODULE
CFLAGS_SL_MODULE
CFLAGS_VECTORIZE
CFLAGS_UNROLL_LOOPS
+PERMIT_MISSING_VARIABLE_DECLARATIONS
PERMIT_DECLARATION_AFTER_STATEMENT
LLVM_BINPATH
LLVM_CXXFLAGS
@@ -6022,6 +6023,54 @@ if test x"$pgac_cv_prog_CXX_cxxflags__Wformat_security" = x"yes"; then
fi
+ # gcc 14+, clang for a while
+ # (Supported in C++ by clang but not gcc. For consistency, omit in C++.)
+ save_CFLAGS=$CFLAGS
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wmissing-variable-declarations, for CFLAGS" >&5
+$as_echo_n "checking whether ${CC} supports -Wmissing-variable-declarations, for CFLAGS... " >&6; }
+if ${pgac_cv_prog_CC_cflags__Wmissing_variable_declarations+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ pgac_save_CFLAGS=$CFLAGS
+pgac_save_CC=$CC
+CC=${CC}
+CFLAGS="${CFLAGS} -Wmissing-variable-declarations"
+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__Wmissing_variable_declarations=yes
+else
+ pgac_cv_prog_CC_cflags__Wmissing_variable_declarations=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__Wmissing_variable_declarations" >&5
+$as_echo "$pgac_cv_prog_CC_cflags__Wmissing_variable_declarations" >&6; }
+if test x"$pgac_cv_prog_CC_cflags__Wmissing_variable_declarations" = x"yes"; then
+ CFLAGS="${CFLAGS} -Wmissing-variable-declarations"
+fi
+
+
+ PERMIT_MISSING_VARIABLE_DECLARATIONS=
+ if test x"$save_CFLAGS" != x"$CFLAGS"; then
+ PERMIT_MISSING_VARIABLE_DECLARATIONS=-Wno-missing-variable-declarations
+ fi
+
# Disable strict-aliasing rules; needed for gcc 3.3+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -fno-strict-aliasing, for CFLAGS" >&5