Use -Wshadow=local if supported

This commit is contained in:
Jay Berkenbilt 2020-04-16 12:40:53 -04:00
parent 92d3cbecd4
commit 734ab58764
3 changed files with 79 additions and 24 deletions

View File

@ -1,4 +1,4 @@
c9b8555013e70c93572e0be5f5c7c03c6b7e0680de4870010945357a02909eaa configure.ac
be950d7be6b0aa2c9c926ac43ca9478ef864b1cb2c8184fd393c9ce4c0972bcc configure.ac
d3f9ee6f6f0846888d9a10fd3dad2e4b1258be84205426cf04d7cef02d61dad7 aclocal.m4
b0ce6d1dba8effa47d25154b2bb56eddafc997254a0f3f903cf9b6abffc03616 libqpdf/qpdf/qpdf-config.h.in
5297971a0ef90bcd5563eb3f7127a032bb76d3ae2af7258bf13479caf8983a60 m4/ax_cxx_compile_stdcxx.m4

69
configure vendored
View File

@ -785,7 +785,6 @@ enable_largefile
enable_ld_version_script
with_buildrules
enable_werror
enable_int_warnings
enable_implicit_crypto
enable_crypto_native
enable_crypto_openssl
@ -1473,8 +1472,6 @@ Optional Features:
--enable-ld-version-script
enable linker version script (default is enabled)
--enable-werror whether to treat warnings as errors (default is no)
--enable-int-warnings whether to turn on integer type warnings (default is
yes)
--enable-implicit-crypto
whether to enable available crypto providers that
are not explicitly requested; true by default
@ -17631,26 +17628,70 @@ if test "$BUILDRULES" = "msvc"; then
else
try_flags="-Wconversion -Wsign-conversion"
fi
oCFLAGS=$CFLAGS
CFLAGS="$CFLAGS $try_flags"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for whether to use $try_flags" >&5
$as_echo_n "checking for whether to use $try_flags... " >&6; }
# Check whether --enable-int-warnings was given.
if test "${enable_int_warnings+set}" = set; then :
enableval=$enable_int_warnings; if test "$enableval" = "yes"; then
qpdf_INT_WARNINGS=1;
else
qpdf_INT_WARNINGS=0;
fi
else
qpdf_INT_WARNINGS=1
fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
int a = 1; int b = a; a = b;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
qpdf_INT_WARNINGS=1
else
qpdf_INT_WARNINGS=0
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test "$qpdf_INT_WARNINGS" = "1"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
WFLAGS="$WFLAGS $try_flags"
CXXFLAGS="$CXXFLAGS $try_flags"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
CFLAGS=$oCFLAGS
fi
if test "$BUILDRULES" != "msvc"; then
try_flags="-Wshadow=local"
oCFLAGS=$CFLAGS
CFLAGS="$CFLAGS $try_flags -Werror"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for whether to use $try_flags" >&5
$as_echo_n "checking for whether to use $try_flags... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
int a = 1; int b = a; a = b;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
qpdf_SHADOW_WARNINGS=1
else
qpdf_SHADOW_WARNINGS=0
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test "$qpdf_SHADOW_WARNINGS" = "1"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
CFLAGS="$oCFLAGS $try_flags"
CXXFLAGS="$CXXFLAGS $try_flags"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
CFLAGS=$oCFLAGS
fi
fi

View File

@ -475,20 +475,34 @@ if test "$BUILDRULES" = "msvc"; then
else
try_flags="-Wconversion -Wsign-conversion"
fi
oCFLAGS=$CFLAGS
CFLAGS="$CFLAGS $try_flags"
AC_MSG_CHECKING(for whether to use $try_flags)
AC_ARG_ENABLE(int-warnings,
AS_HELP_STRING([--enable-int-warnings],
[whether to turn on integer type warnings (default is yes)]),
[if test "$enableval" = "yes"; then
qpdf_INT_WARNINGS=1;
else
qpdf_INT_WARNINGS=0;
fi], [qpdf_INT_WARNINGS=1])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int a = 1; int b = a; a = b;]])],
[qpdf_INT_WARNINGS=1],[qpdf_INT_WARNINGS=0])
if test "$qpdf_INT_WARNINGS" = "1"; then
AC_MSG_RESULT(yes)
WFLAGS="$WFLAGS $try_flags"
CXXFLAGS="$CXXFLAGS $try_flags"
else
AC_MSG_RESULT(no)
CFLAGS=$oCFLAGS
fi
if test "$BUILDRULES" != "msvc"; then
try_flags="-Wshadow=local"
oCFLAGS=$CFLAGS
CFLAGS="$CFLAGS $try_flags -Werror"
AC_MSG_CHECKING(for whether to use $try_flags)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int a = 1; int b = a; a = b;]])],
[qpdf_SHADOW_WARNINGS=1],[qpdf_SHADOW_WARNINGS=0])
if test "$qpdf_SHADOW_WARNINGS" = "1"; then
AC_MSG_RESULT(yes)
CFLAGS="$oCFLAGS $try_flags"
CXXFLAGS="$CXXFLAGS $try_flags"
else
AC_MSG_RESULT(no)
CFLAGS=$oCFLAGS
fi
fi
AC_SUBST(WINDOWS_WMAIN_XLINK_FLAGS)