summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2025-05-26 08:49:19 +0200
committerFlorian Weimer <fweimer@redhat.com>2025-05-26 08:49:22 +0200
commit4f4c4fcde76aedc1f5362a51d98ebb57a28fbce9 (patch)
tree0b48f7ff75de6ed0271cf6614279962b9107d5bb
parent319f94dea2b7eeff12adb22ee50b46b64dd6a52d (diff)
Turn on -Wfree-labels by default if available
This flags a hazard for backporting changes to earlier branches. Reviewed-by: Sam James <sam@gentoo.org>
-rw-r--r--Makeconfig3
-rwxr-xr-xconfigure61
-rw-r--r--configure.ac11
3 files changed, 74 insertions, 1 deletions
diff --git a/Makeconfig b/Makeconfig
index a2ea4f6a33..d5ca908df4 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -892,7 +892,8 @@ host-test-program-cmd = $(host-built-program-cmd)
endif
# Extra flags to pass to GCC.
-+gccwarn := -Wall -Wwrite-strings -Wundef $(cc-option-wimplicit-fallthrough)
++gccwarn := -Wall -Wwrite-strings -Wundef $(cc-option-wimplicit-fallthrough) \
+ $(cc-option-wfree-labels)
ifeq ($(enable-werror),yes)
+gccwarn += -Werror
endif
diff --git a/configure b/configure
index 7decd93baa..c8fd47caae 100755
--- a/configure
+++ b/configure
@@ -649,6 +649,7 @@ have_selinux
have_libcap
have_libaudit
LIBGD
+libc_cv_test_cc_wfree_labels
libc_cv_test_cc_wimplicit_fallthrough
libc_cv_cc_loop_to_function
libc_cv_test_cc_signaling_nans
@@ -7968,6 +7969,66 @@ config_vars="$config_vars
cc-option-wimplicit-fallthrough = $libc_cv_cc_wimplicit_fallthrough"
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -Wfree-labels" >&5
+printf %s "checking for -Wfree-labels... " >&6; }
+if test ${libc_cv_cc_wfree_labels+y}
+then :
+ printf %s "(cached) " >&6
+else case e in #(
+ e) if { ac_try='${CC-cc} -Werror -Wfree-labels -xc /dev/null -S -o /dev/null'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+then :
+ libc_cv_cc_wfree_labels=-Wfree-labels
+else case e in #(
+ e) libc_cv_cc_wfree_labels= ;;
+esac
+fi ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_wfree_labels" >&5
+printf "%s\n" "$libc_cv_cc_wfree_labels" >&6; }
+if test "$TEST_CC" = "$CC"; then
+ libc_cv_test_cc_wfree_labels=$libc_cv_cc_wfree_labels
+else
+
+saved_CC="$CC"
+CC="$TEST_CC"
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -Wfree-labels in testing" >&5
+printf %s "checking for -Wfree-labels in testing... " >&6; }
+if test ${libc_cv_test_cc_wfree_labels+y}
+then :
+ printf %s "(cached) " >&6
+else case e in #(
+ e) if { ac_try='${CC-cc} -Werror -Wfree-labels -xc /dev/null -S -o /dev/null'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+then :
+ libc_cv_test_cc_wfree_labels=-Wfree-labels
+else case e in #(
+ e) libc_cv_test_cc_wfree_labels= ;;
+esac
+fi ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_cc_wfree_labels" >&5
+printf "%s\n" "$libc_cv_test_cc_wfree_labels" >&6; }
+
+CC="$saved_CC"
+
+fi
+
+config_vars="$config_vars
+cc-option-wfree-labels = $libc_cv_cc_wfree_labels"
+
+
conftest_code="
void bar (void (*callback) (void));
int foo (void)
diff --git a/configure.ac b/configure.ac
index abd3b238d2..6cf66c82a1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1575,6 +1575,17 @@ LIBC_CONFIG_VAR([cc-option-wimplicit-fallthrough],
[$libc_cv_cc_wimplicit_fallthrough])
AC_SUBST(libc_cv_test_cc_wimplicit_fallthrough)
+LIBC_TRY_CC_AND_TEST_CC_OPTION([for -Wfree-labels],
+ [-Werror -Wfree-labels],
+ libc_cv_cc_wfree_labels,
+ [libc_cv_cc_wfree_labels=-Wfree-labels],
+ [libc_cv_cc_wfree_labels=],
+ libc_cv_test_cc_wfree_labels,
+ [libc_cv_test_cc_wfree_labels=-Wfree-labels],
+ [libc_cv_test_cc_wfree_labels=])
+LIBC_CONFIG_VAR([cc-option-wfree-labels], [$libc_cv_cc_wfree_labels])
+AC_SUBST(libc_cv_test_cc_wfree_labels)
+
conftest_code="
void bar (void (*callback) (void));
int foo (void)