[libcxx-commits] [libcxx] cd66970 - [libc++] Don't try to include <Block.h> when not available

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Apr 22 12:22:29 PDT 2020


Author: Louis Dionne
Date: 2020-04-22T15:22:12-04:00
New Revision: cd66970b371240d90e163d2020c1a42bb2b7e1b9

URL: https://github.com/llvm/llvm-project/commit/cd66970b371240d90e163d2020c1a42bb2b7e1b9
DIFF: https://github.com/llvm/llvm-project/commit/cd66970b371240d90e163d2020c1a42bb2b7e1b9.diff

LOG: [libc++] Don't try to include <Block.h> when not available

Added: 
    

Modified: 
    libcxx/include/functional
    libcxx/test/libcxx/utilities/function.objects/func.blocks.sh.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/include/functional b/libcxx/include/functional
index f03ba8bb5541..360ca6e32005 100644
--- a/libcxx/include/functional
+++ b/libcxx/include/functional
@@ -508,7 +508,7 @@ POLICY:  For non-variadic implementations, the number of arguments is limited
 
 #include <__functional_base>
 
-#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && !defined(_LIBCPP_HAS_OBJC_ARC)
+#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && !defined(_LIBCPP_HAS_OBJC_ARC) && __has_include(<Block.h>)
 #include <Block.h>
 #endif
 
@@ -2255,7 +2255,7 @@ template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)>
 #endif // _LIBCPP_NO_RTTI
 };
 
-#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && !defined(_LIBCPP_HAS_OBJC_ARC)
+#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && !defined(_LIBCPP_HAS_OBJC_ARC) && __has_include(<Block.h>)
 
 template<class _Rp1, class ..._ArgTypes1, class _Alloc, class _Rp, class ..._ArgTypes>
 class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)>

diff  --git a/libcxx/test/libcxx/utilities/function.objects/func.blocks.sh.cpp b/libcxx/test/libcxx/utilities/function.objects/func.blocks.sh.cpp
index a608d42eb515..25b95465485e 100644
--- a/libcxx/test/libcxx/utilities/function.objects/func.blocks.sh.cpp
+++ b/libcxx/test/libcxx/utilities/function.objects/func.blocks.sh.cpp
@@ -14,6 +14,8 @@
 // RUN: %{build} -fblocks
 // RUN: %{run}
 
+#if __has_include(<Block.h>)
+
 #include <functional>
 #include <cstdlib>
 #include <cassert>
@@ -140,3 +142,9 @@ int main(int, char**)
 
     return 0;
 }
+
+#else
+
+int main() { }
+
+#endif


        


More information about the libcxx-commits mailing list