mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-24 03:32:35 +08:00
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. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@303956 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1126,6 +1126,10 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
|
|||||||
# define _LIBCPP_HAS_NO_IS_AGGREGATE
|
# define _LIBCPP_HAS_NO_IS_AGGREGATE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L
|
||||||
|
# define _LIBCPP_HAS_NO_COROUTINES
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
// Decide whether to use availability macros.
|
// Decide whether to use availability macros.
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ template <class P> struct hash<coroutine_handle<P>>;
|
|||||||
#pragma GCC system_header
|
#pragma GCC system_header
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __cpp_coroutines
|
#ifdef _LIBCPP_HAS_NO_COROUTINES
|
||||||
# if defined(_LIBCPP_WARNING)
|
# if defined(_LIBCPP_WARNING)
|
||||||
_LIBCPP_WARNING("<experimental/coroutine> cannot be used with this compiler")
|
_LIBCPP_WARNING("<experimental/coroutine> cannot be used with this compiler")
|
||||||
# else
|
# else
|
||||||
@@ -67,6 +67,8 @@ template <class P> struct hash<coroutine_handle<P>>;
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef _LIBCPP_HAS_NO_COROUTINES
|
||||||
|
|
||||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_COROUTINES
|
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_COROUTINES
|
||||||
|
|
||||||
template <class _Tp, class = void>
|
template <class _Tp, class = void>
|
||||||
@@ -88,8 +90,6 @@ struct _LIBCPP_TEMPLATE_VIS coroutine_traits
|
|||||||
template <typename _Promise = void>
|
template <typename _Promise = void>
|
||||||
class _LIBCPP_TEMPLATE_VIS coroutine_handle;
|
class _LIBCPP_TEMPLATE_VIS coroutine_handle;
|
||||||
|
|
||||||
#if defined(__cpp_coroutines)
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class _LIBCPP_TEMPLATE_VIS coroutine_handle<void> {
|
class _LIBCPP_TEMPLATE_VIS coroutine_handle<void> {
|
||||||
public:
|
public:
|
||||||
@@ -235,8 +235,6 @@ struct _LIBCPP_TYPE_VIS suspend_always {
|
|||||||
void await_resume() const noexcept {}
|
void await_resume() const noexcept {}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // defined(__cpp_coroutines)
|
|
||||||
|
|
||||||
_LIBCPP_END_NAMESPACE_EXPERIMENTAL_COROUTINES
|
_LIBCPP_END_NAMESPACE_EXPERIMENTAL_COROUTINES
|
||||||
|
|
||||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||||
@@ -251,4 +249,6 @@ struct hash<_VSTD_CORO::coroutine_handle<_Tp> > {
|
|||||||
|
|
||||||
_LIBCPP_END_NAMESPACE_STD
|
_LIBCPP_END_NAMESPACE_STD
|
||||||
|
|
||||||
|
#endif // !defined(_LIBCPP_HAS_NO_COROUTINES)
|
||||||
|
|
||||||
#endif /* _LIBCPP_EXPERIMENTAL_COROUTINE */
|
#endif /* _LIBCPP_EXPERIMENTAL_COROUTINE */
|
||||||
|
|||||||
Reference in New Issue
Block a user