Suppress -Wshadow for SYNCHRONIZED
authorBlake Matheny <bmatheny@fb.com>
Wed, 28 Oct 2015 18:07:40 +0000 (11:07 -0700)
committerfacebook-github-bot-4 <folly-bot@fb.com>
Wed, 28 Oct 2015 19:20:20 +0000 (12:20 -0700)
Summary: SYNCHRONIZED warns with -Wshadow due to `for (auto&
FB_ARG_1(__VA_ARGS__) =`. This diff just suppresses that warning.

Reviewed By: djwatson

Differential Revision: D2587348

fb-gh-sync-id: 3a2e39fb6ce28da014950ca94e4b62ea80deb65f

folly/Synchronized.h

index 312d33743fa6a37b12b3e1d8da750de92b6927d6..dcc5f7dd775cedb0138a6c392e6630f234d7af57 100644 (file)
@@ -673,13 +673,16 @@ void swap(Synchronized<T, M>& lhs, Synchronized<T, M>& rhs) {
  * examples.
  */
 #define SYNCHRONIZED(...)                                       \
+  _Pragma("GCC diagnostic push")                                \
+  _Pragma("GCC diagnostic ignored \"-Wshadow\"")                \
   if (bool SYNCHRONIZED_state = false) {} else                  \
     for (auto SYNCHRONIZED_lockedPtr =                          \
            (FB_ARG_2_OR_1(__VA_ARGS__)).operator->();           \
          !SYNCHRONIZED_state; SYNCHRONIZED_state = true)        \
       for (auto& FB_ARG_1(__VA_ARGS__) =                        \
              *SYNCHRONIZED_lockedPtr.operator->();              \
-           !SYNCHRONIZED_state; SYNCHRONIZED_state = true)
+           !SYNCHRONIZED_state; SYNCHRONIZED_state = true)      \
+  _Pragma("GCC diagnostic pop")
 
 #define TIMED_SYNCHRONIZED(timeout, ...)                           \
   if (bool SYNCHRONIZED_state = false) {} else                     \