From: Mark Wielaard Date: Sat, 7 Feb 2026 17:25:09 +0000 (+0100) Subject: configure: Add -Wdeprecated-non-prototype and -Wfree-labels if available X-Git-Tag: elfutils-0.195~63 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45bf7360166b30465d5aebb7822f93c26f370b1b;p=thirdparty%2Felfutils.git configure: Add -Wdeprecated-non-prototype and -Wfree-labels if available 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 Reviewed-by: Sam James --- diff --git a/config/eu.am b/config/eu.am index 756e7058..321591f7 100644 --- a/config/eu.am +++ b/config/eu.am @@ -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 +## Copyright (C) 2023, 2025, 2026 Mark J. Wielaard ## ## 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)) \ diff --git a/configure.ac b/configure.ac index c9287039..f22a3f90 100644 --- a/configure.ac +++ b/configure.ac @@ -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 +dnl Copyright (C) 2022, 2023, 2026 Mark J. Wielaard 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"