From 2c722291069dd5cf5a65288ed3131f96daed5b05 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 25 Jul 2022 16:35:05 +0930 Subject: [PATCH] configure: add -Wshadow=local flag. This will warn us if there are local variables which shadow the same-named variable. Signed-off-by: Rusty Russell --- configure | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/configure b/configure index 4f35f1553..bd7aae297 100755 --- a/configure +++ b/configure @@ -62,6 +62,9 @@ default_cwarnflags() if [ -n "${1##*-O3*}" ] || [ "$3" != "1" ]; then F="$F -Wno-maybe-uninitialized" fi + # Recent clang understands that, but at least our MacOS CI doesn't, so keep + # this gcc-only. + F="$F -Wshadow=local" fi echo "$F" } @@ -223,6 +226,11 @@ for opt in "$@"; do if [ x"$COPTFLAGS" = x"$DEFAULT_COPTFLAGS" ]; then unset COPTFLAGS fi + # If they didn't have -Wshadow=local, add it on --reconfigure + # (we only added it later) + if [ x"${CWARNFLAGS%*-Wshadow=local}" = x"$CWARNFLAGS" ]; then + unset CWARNFLAGS + fi ;; CC=*) CC="${opt#CC=}";; CONFIGURATOR_CC=*) CONFIGURATOR_CC="${opt#CONFIGURATOR_CC=}";;