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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2022-07-25 16:35:05 +09:30 committed by neil saitug
parent 44d9e8d9c5
commit 2c72229106

8
configure vendored
View file

@ -62,6 +62,9 @@ default_cwarnflags()
if [ -n "${1##*-O3*}" ] || [ "$3" != "1" ]; then if [ -n "${1##*-O3*}" ] || [ "$3" != "1" ]; then
F="$F -Wno-maybe-uninitialized" F="$F -Wno-maybe-uninitialized"
fi fi
# Recent clang understands that, but at least our MacOS CI doesn't, so keep
# this gcc-only.
F="$F -Wshadow=local"
fi fi
echo "$F" echo "$F"
} }
@ -223,6 +226,11 @@ for opt in "$@"; do
if [ x"$COPTFLAGS" = x"$DEFAULT_COPTFLAGS" ]; then if [ x"$COPTFLAGS" = x"$DEFAULT_COPTFLAGS" ]; then
unset COPTFLAGS unset COPTFLAGS
fi 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=}";; CC=*) CC="${opt#CC=}";;
CONFIGURATOR_CC=*) CONFIGURATOR_CC="${opt#CONFIGURATOR_CC=}";; CONFIGURATOR_CC=*) CONFIGURATOR_CC="${opt#CONFIGURATOR_CC=}";;