Author: ericwf
Date: Thu May 25 20:52:59 2017
New Revision: 303956

URL: http://llvm.org/viewvc/llvm-project?rev=303956&view=rev
Log:
Guard <experimental/coroutine> against older Clang versions.

Clang started providing -fcoroutines and defining __cpp_coroutines
way before it implemented the __builtin_coro_foo functions. This
means that simply checking if __cpp_coroutines is not a sufficient
way of detecting the actual feature.

This patch implements _LIBCPP_HAS_NO_COROUTINES which implements
a slightly more complex feature check. Specifically it requires
__cpp_coroutines >= 201703L, which only holds for Clang 5.0 built
after 2017/05/24.

Modified:
    libcxx/trunk/include/__config
    libcxx/trunk/include/experimental/coroutine

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=303956&r1=303955&r2=303956&view=diff
==============================================================================
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Thu May 25 20:52:59 2017
@@ -1126,6 +1126,10 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 # define _LIBCPP_HAS_NO_IS_AGGREGATE
 #endif
 
+#if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L
+# define _LIBCPP_HAS_NO_COROUTINES
+#endif
+
 #endif // __cplusplus
 
 // Decide whether to use availability macros.

Modified: libcxx/trunk/include/experimental/coroutine
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/coroutine?rev=303956&r1=303955&r2=303956&view=diff
==============================================================================
--- libcxx/trunk/include/experimental/coroutine (original)
+++ libcxx/trunk/include/experimental/coroutine Thu May 25 20:52:59 2017
@@ -59,7 +59,7 @@ template <class P> struct hash<coroutine
 #pragma GCC system_header
 #endif
 
-#ifndef __cpp_coroutines
+#ifdef _LIBCPP_HAS_NO_COROUTINES
 # if defined(_LIBCPP_WARNING)
     _LIBCPP_WARNING("<experimental/coroutine> cannot be used with this 
compiler")
 # else
@@ -67,6 +67,8 @@ template <class P> struct hash<coroutine
 # endif
 #endif
 
+#ifndef _LIBCPP_HAS_NO_COROUTINES
+
 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_COROUTINES
 
 template <class _Tp, class = void>
@@ -88,8 +90,6 @@ struct _LIBCPP_TEMPLATE_VIS coroutine_tr
 template <typename _Promise = void>
 class _LIBCPP_TEMPLATE_VIS coroutine_handle;
 
-#if defined(__cpp_coroutines)
-
 template <>
 class _LIBCPP_TEMPLATE_VIS coroutine_handle<void> {
 public:
@@ -235,8 +235,6 @@ struct _LIBCPP_TYPE_VIS suspend_always {
   void await_resume() const noexcept {}
 };
 
-#endif // defined(__cpp_coroutines)
-
 _LIBCPP_END_NAMESPACE_EXPERIMENTAL_COROUTINES
 
 _LIBCPP_BEGIN_NAMESPACE_STD
@@ -251,4 +249,6 @@ struct hash<_VSTD_CORO::coroutine_handle
 
 _LIBCPP_END_NAMESPACE_STD
 
+#endif // !defined(_LIBCPP_HAS_NO_COROUTINES)
+
 #endif /* _LIBCPP_EXPERIMENTAL_COROUTINE */


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to