Hi Sam,
On Sat, Feb 07, 2026 at 02:05:16AM +0000, Sam James wrote:
> Mark Wielaard <[email protected]> writes:
> > Thanks, I forgot about that. The attached patch contains a configure
> > check to make sure -Wmissing-parameter-name is available. Adding it
> > did catch the same issue with gcc.
>
> LGTM. There is -Wdeprecated-non-prototype and also -Wfree-labels for
> some other C23ish issues.
The attached patch adds those warning too. But they didn't catch any
issues in the current codebase.
> Reviewed-by: Sam James <[email protected]>
Thanks. Pushed with that tag.
Cheers,
Mark
>From d07f015b7365c0db1f7b4cf3e13311fa64d40f94 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <[email protected]>
Date: Sat, 7 Feb 2026 18:25:09 +0100
Subject: [PATCH] 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 <[email protected]>
---
config/eu.am | 15 ++++++++++++++-
configure.ac | 22 +++++++++++++++++++++-
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/config/eu.am b/config/eu.am
index 756e7058e9c2..321591f70ba1 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 <[email protected]>
+## Copyright (C) 2023, 2025, 2026 Mark J. Wielaard <[email protected]>
##
## 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 c9287039955d..f22a3f907a88 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 <[email protected]>
+dnl Copyright (C) 2022, 2023, 2026 Mark J. Wielaard <[email protected]>
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"
--
2.52.0