folly (easy): Disable GCC-specific warning disabling hacks in clang
authorBen Gertzfield <beng@fb.com>
Mon, 11 Mar 2013 18:27:34 +0000 (11:27 -0700)
committerJordan DeLong <jdelong@fb.com>
Tue, 19 Mar 2013 00:08:32 +0000 (17:08 -0700)
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

folly/FBString.h
folly/Optional.h

index 5f76d2a68a9655e90c3aee35002b6344a2552ec5..7c465870e9fad0a03c5731e448b2019a36b37b9f 100644 (file)
@@ -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
 /**
index b168b59a768f825eb77c7e0334dc5fafdb99abea..82070889e32d17a812af444b8b474532bb626e6c 100644 (file)
@@ -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<Optional<Value>,
   bool hasValue_;
 };
 
+#if defined(__GNUC__) && !defined(__clang__)
 #pragma GCC diagnostic pop
+#endif
 
 template<class T>
 const T* get_pointer(const Optional<T>& opt) {