From f3199c1a9236f6d89fcbfcb7da4d58c9863f8928 Mon Sep 17 00:00:00 2001 From: Blake Matheny Date: Wed, 28 Oct 2015 11:07:40 -0700 Subject: [PATCH] Suppress -Wshadow for SYNCHRONIZED 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/folly/Synchronized.h b/folly/Synchronized.h index 312d3374..dcc5f7dd 100644 --- a/folly/Synchronized.h +++ b/folly/Synchronized.h @@ -673,13 +673,16 @@ void swap(Synchronized& lhs, Synchronized& 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 \ -- 2.34.1