]> The Tcpdump Group git mirrors - tcpdump/commitdiff
autoconf: Add some warning flags for clang 13 or newer
authorFrancois-Xavier Le Bail <[email protected]>
Fri, 28 Jul 2023 13:03:39 +0000 (15:03 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Fri, 13 Oct 2023 09:37:44 +0000 (11:37 +0200)
-Wnull-pointer-subtraction
-Wunused-but-set-parameter
-Wunused-but-set-variable

(cherry picked from commit 54974c98c5bf1b1499185622043b527152e67b42)

Moreover:
Run autoreconf2.69 -f.

aclocal.m4
configure

index 4cf514e7aebd1de2cc27599061d33d871d24d28a..7725dd04dd6c8596e0680b97f3ed8b4e84cde42c 100644 (file)
@@ -938,6 +938,7 @@ AC_DEFUN(AC_LBL_DEVEL,
                    AC_LBL_CHECK_COMPILER_OPT($1, -Wcast-qual)
                    AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes)
                    AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-variable-declarations)
+                   AC_LBL_CHECK_COMPILER_OPT($1, -Wnull-pointer-subtraction)
                    AC_LBL_CHECK_COMPILER_OPT($1, -Wold-style-definition)
                    AC_LBL_CHECK_COMPILER_OPT($1, -Wpedantic)
                    AC_LBL_CHECK_COMPILER_OPT($1, -Wpointer-arith)
@@ -946,6 +947,8 @@ AC_DEFUN(AC_LBL_DEVEL,
                    AC_LBL_CHECK_COMPILER_OPT($1, -Wsign-compare)
                    AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes)
                    AC_LBL_CHECK_COMPILER_OPT($1, -Wunreachable-code-return)
+                   AC_LBL_CHECK_COMPILER_OPT($1, -Wunused-but-set-parameter)
+                   AC_LBL_CHECK_COMPILER_OPT($1, -Wunused-but-set-variable)
                    AC_LBL_CHECK_COMPILER_OPT($1, -Wused-but-marked-unused)
                    AC_LBL_CHECK_COMPILER_OPT($1, -Wwrite-strings)
            fi
index 4b06488b8d09c51c75e6d9dbadff485ecb84b53c..3071a3daa2d198ad063e350cf6fbe256c04e8c87 100755 (executable)
--- a/configure
+++ b/configure
@@ -7415,6 +7415,58 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
        ac_c_werror_flag="$save_ac_c_werror_flag"
 
 
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wnull-pointer-subtraction option" >&5
+$as_echo_n "checking whether the compiler supports the -Wnull-pointer-subtraction option... " >&6; }
+       save_CFLAGS="$CFLAGS"
+       CFLAGS="$CFLAGS -Wnull-pointer-subtraction"
+       #
+       # XXX - yes, this depends on the way AC_LANG_WERROR works,
+       # but no mechanism is provided to turn AC_LANG_WERROR on
+       # *and then turn it back off*, so that we *only* do it when
+       # testing compiler options - 15 years after somebody asked
+       # for it:
+       #
+       #     https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+       #
+       save_ac_c_werror_flag="$ac_c_werror_flag"
+       ac_c_werror_flag=yes
+       #
+       # We use AC_LANG_SOURCE() so that we can control the complete
+       # content of the program being compiled.  We do not, for example,
+       # want the default "int main()" that AC_LANG_PROGRAM() generates,
+       # as it will generate a warning with -Wold-style-definition, meaning
+       # that we would treat it as not working, as the test will fail if
+       # *any* error output, including a warning due to the flag we're
+       # testing, is generated; see
+       #
+       #    https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+       #    https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+       #
+       # This may, as per those two messages, be fixed in autoconf 2.70,
+       # but we only require 2.69 or newer for now.
+       #
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int main(void) { return 0; }
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+               { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+               CFLAGS="$save_CFLAGS"
+               V_CCOPT="$V_CCOPT -Wnull-pointer-subtraction"
+
+else
+
+               { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+               CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       ac_c_werror_flag="$save_ac_c_werror_flag"
+
+
        { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wold-style-definition option" >&5
 $as_echo_n "checking whether the compiler supports the -Wold-style-definition option... " >&6; }
        save_CFLAGS="$CFLAGS"
@@ -7831,6 +7883,110 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
        ac_c_werror_flag="$save_ac_c_werror_flag"
 
 
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wunused-but-set-parameter option" >&5
+$as_echo_n "checking whether the compiler supports the -Wunused-but-set-parameter option... " >&6; }
+       save_CFLAGS="$CFLAGS"
+       CFLAGS="$CFLAGS -Wunused-but-set-parameter"
+       #
+       # XXX - yes, this depends on the way AC_LANG_WERROR works,
+       # but no mechanism is provided to turn AC_LANG_WERROR on
+       # *and then turn it back off*, so that we *only* do it when
+       # testing compiler options - 15 years after somebody asked
+       # for it:
+       #
+       #     https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+       #
+       save_ac_c_werror_flag="$ac_c_werror_flag"
+       ac_c_werror_flag=yes
+       #
+       # We use AC_LANG_SOURCE() so that we can control the complete
+       # content of the program being compiled.  We do not, for example,
+       # want the default "int main()" that AC_LANG_PROGRAM() generates,
+       # as it will generate a warning with -Wold-style-definition, meaning
+       # that we would treat it as not working, as the test will fail if
+       # *any* error output, including a warning due to the flag we're
+       # testing, is generated; see
+       #
+       #    https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+       #    https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+       #
+       # This may, as per those two messages, be fixed in autoconf 2.70,
+       # but we only require 2.69 or newer for now.
+       #
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int main(void) { return 0; }
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+               { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+               CFLAGS="$save_CFLAGS"
+               V_CCOPT="$V_CCOPT -Wunused-but-set-parameter"
+
+else
+
+               { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+               CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       ac_c_werror_flag="$save_ac_c_werror_flag"
+
+
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wunused-but-set-variable option" >&5
+$as_echo_n "checking whether the compiler supports the -Wunused-but-set-variable option... " >&6; }
+       save_CFLAGS="$CFLAGS"
+       CFLAGS="$CFLAGS -Wunused-but-set-variable"
+       #
+       # XXX - yes, this depends on the way AC_LANG_WERROR works,
+       # but no mechanism is provided to turn AC_LANG_WERROR on
+       # *and then turn it back off*, so that we *only* do it when
+       # testing compiler options - 15 years after somebody asked
+       # for it:
+       #
+       #     https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+       #
+       save_ac_c_werror_flag="$ac_c_werror_flag"
+       ac_c_werror_flag=yes
+       #
+       # We use AC_LANG_SOURCE() so that we can control the complete
+       # content of the program being compiled.  We do not, for example,
+       # want the default "int main()" that AC_LANG_PROGRAM() generates,
+       # as it will generate a warning with -Wold-style-definition, meaning
+       # that we would treat it as not working, as the test will fail if
+       # *any* error output, including a warning due to the flag we're
+       # testing, is generated; see
+       #
+       #    https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+       #    https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+       #
+       # This may, as per those two messages, be fixed in autoconf 2.70,
+       # but we only require 2.69 or newer for now.
+       #
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int main(void) { return 0; }
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+               { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+               CFLAGS="$save_CFLAGS"
+               V_CCOPT="$V_CCOPT -Wunused-but-set-variable"
+
+else
+
+               { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+               CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       ac_c_werror_flag="$save_ac_c_werror_flag"
+
+
        { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wused-but-marked-unused option" >&5
 $as_echo_n "checking whether the compiler supports the -Wused-but-marked-unused option... " >&6; }
        save_CFLAGS="$CFLAGS"