]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
configure: Add -Wdeprecated-non-prototype and -Wfree-labels if available
authorMark Wielaard <mark@klomp.org>
Sat, 7 Feb 2026 17:25:09 +0000 (18:25 +0100)
committerMark Wielaard <mark@klomp.org>
Mon, 9 Feb 2026 17:30:48 +0000 (18:30 +0100)
Calling a function with one or more arguments declared with an empty
parameter list is an error in C23. In C23 labels applied to
non-statements are allowed, but not in earlier standards (they are as
GNU extension in GCC). Add -Wdeprecated-non-prototype and
-Wfree-labels (available since GCC 15) to catch this.

            * configure.ac: Add HAVE_DEPRECATED_NON_PROTOTYPE_WARNING
    and HAVE_FREE_LABELS_WARNING check.
            * config/eu.am: Set FREE_LABELS_WARNING and
    FREE_LABELS_WARNING.
            (AM_CFLAGS): Add DEPRECATED_NON_PROTOTYPE_WARNING and
    FREE_LABELS_WARNING.

Signed-off-by: Mark Wielaard <mark@klomp.org>
Reviewed-by: Sam James <sam@gentoo.org>
config/eu.am
configure.ac

index 756e7058e9c2309a0ff64573fa70cdfb06ca52c5..321591f70ba18f0dd598721ecaffd20ba138803f 100644 (file)
@@ -1,7 +1,7 @@
 ## Common automake fragments for elfutils subdirectory makefiles.
 ##
 ## Copyright (C) 2010, 2014, 2016 Red Hat, Inc.
-## Copyright (C) 2023, 2025 Mark J. Wielaard <mark@klomp.org>
+## Copyright (C) 2023, 2025, 2026 Mark J. Wielaard <mark@klomp.org>
 ##
 ## This file is part of elfutils.
 ##
@@ -117,11 +117,24 @@ else
 MISSING_PARAMETER_NAME_WARNING=
 endif
 
+if HAVE_DEPRECATED_NON_PROTOTYPE_WARNING
+DEPRECATED_NON_PROTOTYPE_WARNING=-Wdeprecated-non-prototype
+else
+DEPRECATED_NON_PROTOTYPE_WARNING=
+endif
+
+if HAVE_FREE_LABELS_WARNING
+FREE_LABELS_WARNINGS=-Wfree-labels
+else
+FREE_LABELS_WARNING=
+endif
+
 AM_CFLAGS = -Wall -Wshadow -Wformat=2 \
            -Wold-style-definition -Wstrict-prototypes $(TRAMPOLINES_WARNING) \
            $(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \
            $(NULL_DEREFERENCE_WARNING) $(IMPLICIT_FALLTHROUGH_WARNING) \
            $(USE_AFTER_FREE3_WARNING) $(MISSING_PARAMETER_NAME_WARNING) \
+           $(DEPRECATED_NON_PROTOTYPE_WARNING) $(FREE_LABELS_WARNING) \
            $(if $($(*F)_no_Werror),,-Werror) \
            $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
            $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \
index c9287039955de8890d6d59968f231e66779668c6..f22a3f907a881e11dd526bf54d45b1138bd52959 100644 (file)
@@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script.
 dnl Configure input file for elfutils.                     -*-autoconf-*-
 dnl
 dnl Copyright (C) 1996-2019, 2025 Red Hat, Inc.
-dnl Copyright (C) 2022, 2023 Mark J. Wielaard <mark@klomp.org>
+dnl Copyright (C) 2022, 2023, 2026 Mark J. Wielaard <mark@klomp.org>
 dnl
 dnl This file is part of elfutils.
 dnl
@@ -675,6 +675,26 @@ CFLAGS="$old_CFLAGS"])
 AM_CONDITIONAL(HAVE_MISSING_PARAMETER_NAME_WARNING,
               [test "x$ac_cv_missing_parameter_name" != "xno"])
 
+AC_CACHE_CHECK([whether the compiler accepts -Wdeprecated-non-prototype], ac_cv_deprecated_non_prototype, [dnl
+old_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Wdeprecated-non-prototype -Werror"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
+                 ac_cv_deprecated_non_prototype=yes,
+                 ac_cv_deprecated_non_prototype=no)
+CFLAGS="$old_CFLAGS"])
+AM_CONDITIONAL(HAVE_DEPRECATED_NON_PROTOTYPE_WARNING,
+              [test "x$ac_cv_deprecated_non_prototype" != "xno"])
+
+AC_CACHE_CHECK([whether the compiler accepts -Wfree_labels], ac_cv_free_labels, [dnl
+old_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Wfree-labels -Werror"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
+                 ac_cv_free_labels=yes,
+                 ac_cv_free_labels=no)
+CFLAGS="$old_CFLAGS"])
+AM_CONDITIONAL(HAVE_FREE_LABELS_WARNING,
+              [test "x$ac_cv_free_labels" != "xno"])
+
 AC_CACHE_CHECK([whether the compiler accepts -fno-addrsig], ac_cv_fno_addrsig, [dnl
 old_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -fno-addrsig -Werror"