From: Jim Meyering Date: Sun, 5 Mar 2017 18:32:27 +0000 (-0800) Subject: folly/Foreach.h: avoid shadowing warnings X-Git-Tag: v2017.03.06.00~1 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=623e0f3bd82dedb0478fe768557089ee03bfa890;p=folly.git folly/Foreach.h: avoid shadowing warnings Summary: Fix warnings exposed by gcc's -Wshadow-compatible-local. Don't use a hard-coded names that would cause shadowing with each nested use of this macro. This avoids errors like the following: folly/Foreach.h:94:18: error: declaration of 'FOR_EACH_privateCount' shadows a previous local [-Werror=shadow-compatible-local] folly/Foreach.h:91:12: error: shadowed declaration is here [-Werror=shadow-compatible-local] Reviewed By: yfeldblum Differential Revision: D4656783 fbshipit-source-id: d7cd820fb04ccd78242f7487e2b219dc300709b6 --- diff --git a/folly/Foreach.h b/folly/Foreach.h index 77ef80cc..5cc075c7 100644 --- a/folly/Foreach.h +++ b/folly/Foreach.h @@ -88,13 +88,13 @@ * } */ #define FOR_EACH_ENUMERATE(count, i, c) \ - if (bool FOR_EACH_state1 = false) {} else \ + if (bool _FE_ANON(s1_) = false) {} else \ for (auto && FOR_EACH_state2 = (c); \ - !FOR_EACH_state1; FOR_EACH_state1 = true) \ - if (size_t FOR_EACH_privateCount = 0) {} else \ - if (const size_t& count = FOR_EACH_privateCount) {} else \ + !_FE_ANON(s1_); _FE_ANON(s1_) = true) \ + if (size_t _FE_ANON(n1_) = 0) {} else \ + if (const size_t& count = _FE_ANON(n1_)) {} else \ for (auto i = FOR_EACH_state2.begin(); \ - i != FOR_EACH_state2.end(); ++FOR_EACH_privateCount, ++i) + i != FOR_EACH_state2.end(); ++_FE_ANON(n1_), ++i) /** * Similar to FOR_EACH, but gives the user the key and value for each entry in