build system: only use -Wshadow-compatible-local if compiler supports it

This commit is contained in:
Moritz Bunkus 2018-04-17 23:28:50 +02:00
parent b14349538a
commit 9eaf235c76
3 changed files with 18 additions and 1 deletions

View File

@ -139,7 +139,7 @@ def setup_globals
cflags = "#{cflags_common} #{c(:USER_CFLAGS)}"
cxxflags = "#{cflags_common} #{c(:STD_CXX)}"
cxxflags += " -Wnon-virtual-dtor -Woverloaded-virtual -Wextra -Wno-missing-field-initializers -Wshadow-compatible-local #{c(:WNO_MAYBE_UNINITIALIZED)}"
cxxflags += " -Wnon-virtual-dtor -Woverloaded-virtual -Wextra -Wno-missing-field-initializers #{c(:WSHADOW_COMPATIBLE_LOCAL)} #{c(:WNO_MAYBE_UNINITIALIZED)}"
cxxflags += " #{c(:QT_CFLAGS)} #{c(:BOOST_CPPFLAGS)} #{c(:USER_CXXFLAGS)}"
ldflags = ""

View File

@ -39,6 +39,21 @@ else
fi
fi
AC_CACHE_CHECK([for compiler flag -Wshadow-compatible-local], [ax_cv_wshadow_compatible_local],[
AC_LANG_PUSH(C++)
CXXFLAGS_SAVED="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS_SAVED -Wshadow-compatible-local"
AC_TRY_COMPILE([], [true;], [ax_cv_wshadow_compatible_local="yes"], [ax_cv_wshadow_compatible_local="no"])
AC_LANG_POP
CXXFLAGS="$CXXFLAGS_SAVED"
])
if test x"$ax_cv_wshadow_compatible_local" = xyes; then
WSHADOW_COMPATIBLE_LOCAL="-Wshadow-compatible-local"
fi
AC_SUBST(FSTACK_PROTECTOR)
AC_SUBST(QUNUSED_ARGUMENTS)
AC_SUBST(WNO_SELF_ASSIGN)
@ -47,4 +62,5 @@ AC_SUBST(WLOGICAL_OP)
AC_SUBST(WNO_INCONSISTENT_MISSING_OVERRIDE)
AC_SUBST(WNO_POTENTIALLY_EVALUATED_EXPRESSION)
AC_SUBST(WNO_MAYBE_UNINITIALIZED)
AC_SUBST(WSHADOW_COMPATIBLE_LOCAL)
AC_SUBST(LLVM_LLD)

View File

@ -136,6 +136,7 @@ WNO_MISMATCHED_TAGS = @WNO_MISMATCHED_TAGS@
WNO_MAYBE_UNINITIALIZED = @WNO_MAYBE_UNINITIALIZED@
WNO_POTENTIALLY_EVALUATED_EXPRESSION = @WNO_POTENTIALLY_EVALUATED_EXPRESSION@
WNO_SELF_ASSIGN = @WNO_SELF_ASSIGN@
WSHADOW_COMPATIBLE_LOCAL = @WSHADOW_COMPATIBLE_LOCAL@
XSLTPROC = @XSLTPROC@
XSLTPROC_FLAGS = @XSLTPROC_FLAGS@
ZLIB_LIBS = @ZLIB_LIBS@