Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit d006f324c88d45bb7f01d5fefea2ee2e52c09e2c 1 parent 3031390
@bgertzfield bgertzfield authored jdelong committed
Showing with 7 additions and 1 deletion.
  1. +4 −0 folly/FBString.h
  2. +3 −1 folly/Optional.h
View
4 folly/FBString.h
@@ -248,8 +248,10 @@ class fbstring_core_model {
* 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 @@ template <class Char> class fbstring_core {
}
};
+#if defined(__GNUC__) && !defined(__clang__)
# pragma GCC diagnostic pop
+#endif
#ifndef _LIBSTDCXX_FBSTRING
/**
View
4 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<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) {
Please sign in to comment.
Something went wrong with that request. Please try again.