From: Ben Gertzfield Date: Mon, 11 Mar 2013 18:27:34 +0000 (-0700) Subject: folly (easy): Disable GCC-specific warning disabling hacks in clang X-Git-Tag: v0.22.0~1042 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d006f324c88d45bb7f01d5fefea2ee2e52c09e2c;p=folly.git folly (easy): Disable GCC-specific warning disabling hacks in clang Summary: When compiling folly with clang, the compiler warns about our use of GCC-specific pragmas to silence incorrect compiler warnings: folly/Optional.h:79:33: warning: unknown warning group '-Wpragmas', ignored [-Wunknown-pragmas] folly/Optional.h:80:33: warning: unknown warning group '-Wmaybe-uninitialized', ignored [-Wunknown-pragmas] Thankfully, those incorrect compiler warnings are not emitted by clang, so we can just disable the pragmas in clang. Test Plan: Built folly in gcc and ran it through clang. Warning above is gone. Reviewed By: andrei.alexandrescu@fb.com FB internal diff: D733323 --- diff --git a/folly/FBString.h b/folly/FBString.h index 5f76d2a6..7c465870 100644 --- a/folly/FBString.h +++ b/folly/FBString.h @@ -248,8 +248,10 @@ private: * gcc-4.7 throws what appears to be some false positive uninitialized * warnings for the members of the MediumLarge struct. So, mute them here. */ +#if defined(__GNUC__) && !defined(__clang__) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wuninitialized" +#endif /** * This is the core of the string. The code should work on 32- and @@ -834,7 +836,9 @@ private: } }; +#if defined(__GNUC__) && !defined(__clang__) # pragma GCC diagnostic pop +#endif #ifndef _LIBSTDCXX_FBSTRING /** diff --git a/folly/Optional.h b/folly/Optional.h index b168b59a..82070889 100644 --- a/folly/Optional.h +++ b/folly/Optional.h @@ -73,7 +73,7 @@ const None none = nullptr; * gcc-4.7 warns about use of uninitialized memory around the use of storage_ * even though this is explicitly initialized at each point. */ -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(__clang__) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wuninitialized" # pragma GCC diagnostic ignored "-Wpragmas" @@ -245,7 +245,9 @@ class Optional : boost::totally_ordered, bool hasValue_; }; +#if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic pop +#endif template const T* get_pointer(const Optional& opt) {