]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Turn on -Wfree-labels by default if available
authorFlorian Weimer <fweimer@redhat.com>
Mon, 26 May 2025 06:49:19 +0000 (08:49 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Mon, 26 May 2025 06:49:22 +0000 (08:49 +0200)
This flags a hazard for backporting changes to earlier branches.

Reviewed-by: Sam James <sam@gentoo.org>
Makeconfig
configure
configure.ac

index a2ea4f6a332520bc766c806c0832343884fc4e3d..d5ca908df4badc428108f631229763765d8279e2 100644 (file)
@@ -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
index 7decd93baaf82d2a36882d86e7efa36309467b96..c8fd47caae4e0e00ba3bd203b6cf80a324bf3743 100755 (executable)
--- 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)
index abd3b238d2f4a5fc35c83a26b2390312dd08f2c3..6cf66c82a136c8a57fdc851d9131ff9d05f5fbfb 100644 (file)
@@ -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)