From: Jim Meyering Date: Thu, 20 Oct 2016 14:50:18 +0000 (-0700) Subject: configure.ac: check for -Wshadow-local and -Wshadow-compatible-local X-Git-Tag: v2016.10.24.00~6 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9047707eefac7bf1a5b309afb0d55a970215d08c;p=folly.git configure.ac: check for -Wshadow-local and -Wshadow-compatible-local Summary: Add a configure-time check for whether -Wshadow-local and -Wshadow-compatible-local are supported. If so, arrange to define HAVE_SHADOW_LOCAL_WARNINGS. In Portability.h, use that new symbol to choose whether to define FOLLY_GCC_DISABLE_NEW_SHADOW_WARNINGS, which used pragmas to disable those new warnings. Differential Revision: D4041696 fbshipit-source-id: 520ee88ae55147a13d0a045aca7d86567a8da99d --- diff --git a/folly/Portability.h b/folly/Portability.h index 98ecd030..4dbc3bd3 100644 --- a/folly/Portability.h +++ b/folly/Portability.h @@ -167,6 +167,14 @@ constexpr bool kHasUnalignedAccess = false; # define FOLLY_MSVC_DISABLE_WARNING(warningNumber) #endif +#ifdef HAVE_SHADOW_LOCAL_WARNINGS +#define FOLLY_GCC_DISABLE_NEW_SHADOW_WARNINGS \ + FOLLY_GCC_DISABLE_WARNING(shadow-compatible-local) \ + FOLLY_GCC_DISABLE_WARNING(shadow-local) +#else +#define FOLLY_GCC_DISABLE_NEW_SHADOW_WARNINGS /* empty */ +#endif + #if defined(__GNUC__) && !defined(__APPLE__) && !__GNUC_PREREQ(4,9) // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56019 // gcc 4.8.x incorrectly placed max_align_t in the root namespace diff --git a/folly/configure.ac b/folly/configure.ac index 21cc2ce2..d4acc99b 100644 --- a/folly/configure.ac +++ b/folly/configure.ac @@ -63,6 +63,23 @@ CXXFLAGS="$STD $CXXFLAGS" # expose required -std option via pkg-config PKG_CXXFLAGS=$STD +# See if -Wshadow-local and -Wshadow-compatible-local are supported +AC_MSG_CHECKING( + [whether -Wshadow-local and -Wshadow-compatible-local are supported]) +AC_CACHE_VAL([folly_cv_cxx_shadow_local_support], [ + folly_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -Wshadow-local -Wshadow-compatible-local" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], [[]])], + [folly_cv_cxx_shadow_local_support=yes], + [folly_cv_cxx_shadow_local_support=no]) + CXXFLAGS="$folly_save_CXXFLAGS"]) +AC_MSG_RESULT([$folly_cv_cxx_shadow_local_support]) +if test "$folly_cv_cxx_shadow_local_support" = yes; then + AC_DEFINE([HAVE_SHADOW_LOCAL_WARNINGS], [1], + [Define if both -Wshadow-local and -Wshadow-compatible-local are supported.]) +fi + # Checks for glog and gflags # There are no symbols with C linkage, so we do a try-run AC_HAVE_LIBRARY([gflags],[],[AC_MSG_ERROR(