\r
.. [#note-P0600] P0600: The missing bits in P0600 are in |sect|\ [mem.res.class], |sect|\ [mem.poly.allocator.class], and |sect|\ [container.node.overview].\r
.. [#note-P0966] P0966: It was previously erroneously marked as complete in version 8.0. See `bug 45368 <https://llvm.org/PR45368>`__.\r
-\r
.. [#note-P0619] P0619: Only sections D.8, D.9, and D.10 are implemented. Sections D.4, D.7, D.11, D.12, and D.14 remain undone.\r
+ .. [#note-P0883] P0883: shared_ptr and floating-point changes weren't applied as they themselves aren't implemented yet.\r
\r
\r
.. _issues-status-cxx2a:\r
"`P1661 <https://wg21.link/P1661>`__","LWG","Remove dedicated precalculated hash lookup interface","Cologne","|Nothing To Do|",""
"`P1754 <https://wg21.link/P1754>`__","LWG","Rename concepts to standard_case for C++20, while we still can","Cologne","|In Progress|",""
"","","","","",""
-"`P0883 <https://wg21.link/P0883>`__","LWG","Fixing Atomic Initialization","Belfast","* *",""
+"`P0883 <https://wg21.link/P0883>`__","LWG","Fixing Atomic Initialization","Belfast","|Complete| [#note-P0883]","13.0"
"`P1391 <https://wg21.link/P1391>`__","LWG","Range constructor for std::string_view","Belfast","* *",""
"`P1394 <https://wg21.link/P1394>`__","LWG","Range constructor for std::span","Belfast","* *",""
"`P1456 <https://wg21.link/P1456>`__","LWG","Move-only views","Belfast","* *",""
------------------------------------------------- -----------------
``__cpp_lib_atomic_shared_ptr`` *unimplemented*
------------------------------------------------- -----------------
- ``__cpp_lib_atomic_value_initialization`` *unimplemented*
+ ``__cpp_lib_atomic_value_initialization`` ``201911L``
------------------------------------------------- -----------------
``__cpp_lib_atomic_wait`` ``201907L``
------------------------------------------------- -----------------
bool is_lock_free() const volatile noexcept;
bool is_lock_free() const noexcept;
- atomic() noexcept = default;
+ atomic() noexcept = default; // until C++20
+ constexpr atomic() noexcept(is_nothrow_default_constructible_v<T>); // since C++20
constexpr atomic(T desr) noexcept;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
bool is_lock_free() const volatile noexcept;
bool is_lock_free() const noexcept;
- atomic() noexcept = default;
+ atomic() noexcept = default; // until C++20
+ constexpr atomic() noexcept; // since C++20
constexpr atomic(T* desr) noexcept;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
typedef struct atomic_flag
{
- atomic_flag() noexcept = default;
+ atomic_flag() noexcept = default; // until C++20
+ constexpr atomic_flag() noexcept; // since C++20
atomic_flag(const atomic_flag&) = delete;
atomic_flag& operator=(const atomic_flag&) = delete;
atomic_flag& operator=(const atomic_flag&) volatile = delete;
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_all() _NOEXCEPT
{__cxx_atomic_notify_all(&__a_);}
+#if _LIBCPP_STD_VER > 17
+ _LIBCPP_INLINE_VISIBILITY constexpr
+ __atomic_base() noexcept(is_nothrow_default_constructible_v<_Tp>) : __a_(_Tp()) {}
+#else
_LIBCPP_INLINE_VISIBILITY
__atomic_base() _NOEXCEPT _LIBCPP_DEFAULT
+#endif
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
__atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}
: public __atomic_base<_Tp, false>
{
typedef __atomic_base<_Tp, false> __base;
- _LIBCPP_INLINE_VISIBILITY
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__atomic_base() _NOEXCEPT _LIBCPP_DEFAULT
+
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {}
typedef __atomic_base<_Tp> __base;
typedef _Tp value_type;
typedef value_type difference_type;
+
+#if _LIBCPP_STD_VER > 17
+ _LIBCPP_INLINE_VISIBILITY
+ atomic() = default;
+#else
_LIBCPP_INLINE_VISIBILITY
atomic() _NOEXCEPT _LIBCPP_DEFAULT
+#endif
+
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {}
typedef __atomic_base<_Tp*> __base;
typedef _Tp* value_type;
typedef ptrdiff_t difference_type;
+
_LIBCPP_INLINE_VISIBILITY
atomic() _NOEXCEPT _LIBCPP_DEFAULT
+
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {}
// atomic_init
template <class _Tp>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_INLINE_VISIBILITY
void
atomic_init(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
{
}
template <class _Tp>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_INLINE_VISIBILITY
void
atomic_init(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
{
void notify_all() _NOEXCEPT
{__cxx_atomic_notify_all(&__a_);}
+#if _LIBCPP_STD_VER > 17
+ _LIBCPP_INLINE_VISIBILITY constexpr
+ atomic_flag() _NOEXCEPT : __a_(false) {}
+#else
_LIBCPP_INLINE_VISIBILITY
atomic_flag() _NOEXCEPT _LIBCPP_DEFAULT
+#endif
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} // EXTENSION
// # define __cpp_lib_atomic_shared_ptr 201711L
# endif
# if !defined(_LIBCPP_HAS_NO_THREADS)
-// # define __cpp_lib_atomic_value_initialization 201911L
+# define __cpp_lib_atomic_value_initialization 201911L
# endif
# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait)
# define __cpp_lib_atomic_wait 201907L
//
// UNSUPPORTED: libcpp-has-no-threads, c++03
// REQUIRES: is-lockfree-runtime-function
+// ADDITIONAL_COMPILE_FLAGS: -Wno-psabi
+// ... since C++20 std::__atomic_base initializes, so we get a warning about an
+// ABI change for vector variants since the constructor code for that is
+// different if one were to compile with architecture-specific vector
+// extensions enabled.
+// This however isn't ABI breaking as it was impossible for any code to trigger
+// this without using libc++ internals.
// GCC currently fails because it needs -fabi-version=6 to fix mangling of
// std::atomic when used with __attribute__((vector(X))).
//===----------------------------------------------------------------------===//
//
// UNSUPPORTED: libcpp-has-no-threads
-// ... test case crashes clang.
// <atomic>
{
typedef typename std::remove_pointer<T>::type X;
A obj(T(0));
+ assert(obj == T(0));
bool b0 = obj.is_lock_free();
((void)b0); // mark as unused
- assert(obj == T(0));
- std::atomic_init(&obj, T(1));
- assert(obj == T(1));
- std::atomic_init(&obj, T(2));
- assert(obj == T(2));
obj.store(T(0));
assert(obj == T(0));
obj.store(T(1), std::memory_order_release);
{
volatile std::atomic<bool> obj(true);
assert(obj == true);
- std::atomic_init(&obj, false);
- assert(obj == false);
- std::atomic_init(&obj, true);
- assert(obj == true);
bool b0 = obj.is_lock_free();
(void)b0; // to placate scan-build
obj.store(false);
{
std::atomic<bool> obj(true);
assert(obj == true);
- std::atomic_init(&obj, false);
- assert(obj == false);
- std::atomic_init(&obj, true);
- assert(obj == true);
bool b0 = obj.is_lock_free();
(void)b0; // to placate scan-build
obj.store(false);
{
std::atomic_bool obj(true);
assert(obj == true);
- std::atomic_init(&obj, false);
- assert(obj == false);
- std::atomic_init(&obj, true);
- assert(obj == true);
bool b0 = obj.is_lock_free();
(void)b0; // to placate scan-build
obj.store(false);
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: libcpp-has-no-threads
+
+#include <atomic>
+
+#include "test_macros.h"
+
+template <typename T>
+constexpr bool test() {
+ [[maybe_unused]] constexpr T a;
+ static_assert(std::is_nothrow_constructible_v<T>);
+ ASSERT_NOEXCEPT(T{});
+ return true;
+}
+
+struct throwing {
+ throwing() {}
+};
+
+struct trivial {
+ int a;
+};
+
+void test() {
+ static_assert(test<std::atomic<bool>>());
+ static_assert(test<std::atomic<int>>());
+ static_assert(test<std::atomic<int*>>());
+ static_assert(test<std::atomic<trivial>>());
+ static_assert(test<std::atomic_flag>());
+
+ static_assert(!std::is_nothrow_constructible_v<std::atomic<throwing>>);
+ ASSERT_NOT_NOEXCEPT(std::atomic<throwing>{});
+}
{
A obj(T(0));
assert(obj == T(0));
- std::atomic_init(&obj, T(1));
- assert(obj == T(1));
- std::atomic_init(&obj, T(2));
- assert(obj == T(2));
bool b0 = obj.is_lock_free();
((void)b0); // mark as unused
obj.store(T(0));
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: no-exceptions
+
+// <atomic>
+
+#include <atomic>
+#include <cassert>
+
+struct throwing {
+ throwing() { throw 42; }
+};
+
+int main(int, char**) {
+ try {
+ [[maybe_unused]] std::atomic<throwing> a;
+ assert(false);
+ } catch (int x) {
+ assert(x == 42);
+ }
+
+ return 0;
+}
void operator()() const {
{
typedef std::atomic<T> A;
- A a;
T t(T(1));
- std::atomic_init(&a, t);
+ A a(t);
assert(std::atomic_compare_exchange_strong(&a, &t, T(2)) == true);
assert(a == T(2));
assert(t == T(1));
}
{
typedef std::atomic<T> A;
- volatile A a;
T t(T(1));
- std::atomic_init(&a, t);
+ volatile A a(t);
assert(std::atomic_compare_exchange_strong(&a, &t, T(2)) == true);
assert(a == T(2));
assert(t == T(1));
void operator()() const {
{
typedef std::atomic<T> A;
- A a;
T t(T(1));
- std::atomic_init(&a, t);
+ A a(t);
assert(std::atomic_compare_exchange_strong_explicit(&a, &t, T(2),
std::memory_order_seq_cst, std::memory_order_seq_cst) == true);
assert(a == T(2));
}
{
typedef std::atomic<T> A;
- volatile A a;
T t(T(1));
- std::atomic_init(&a, t);
+ volatile A a(t);
assert(std::atomic_compare_exchange_strong_explicit(&a, &t, T(2),
std::memory_order_seq_cst, std::memory_order_seq_cst) == true);
assert(a == T(2));
void operator()() const {
{
typedef std::atomic<T> A;
- A a;
T t(T(1));
- std::atomic_init(&a, t);
+ A a(t);
assert(c_cmpxchg_weak_loop(&a, &t, T(2)) == true);
assert(a == T(2));
assert(t == T(1));
}
{
typedef std::atomic<T> A;
- volatile A a;
T t(T(1));
- std::atomic_init(&a, t);
+ volatile A a(t);
assert(c_cmpxchg_weak_loop(&a, &t, T(2)) == true);
assert(a == T(2));
assert(t == T(1));
void operator()() const {
{
typedef std::atomic<T> A;
- A a;
T t(T(1));
- std::atomic_init(&a, t);
+ A a(t);
assert(c_cmpxchg_weak_loop(&a, &t, T(2),
std::memory_order_seq_cst, std::memory_order_seq_cst) == true);
assert(a == T(2));
}
{
typedef std::atomic<T> A;
- volatile A a;
T t(T(1));
- std::atomic_init(&a, t);
+ volatile A a(t);
assert(c_cmpxchg_weak_loop(&a, &t, T(2),
std::memory_order_seq_cst, std::memory_order_seq_cst) == true);
assert(a == T(2));
struct TestFn {
void operator()() const {
typedef std::atomic<T> A;
- A t;
- std::atomic_init(&t, T(1));
+ A t(T(1));
assert(std::atomic_exchange(&t, T(2)) == T(1));
assert(t == T(2));
- volatile A vt;
- std::atomic_init(&vt, T(3));
+ volatile A vt(T(3));
assert(std::atomic_exchange(&vt, T(4)) == T(3));
assert(vt == T(4));
}
struct TestFn {
void operator()() const {
typedef std::atomic<T> A;
- A t;
- std::atomic_init(&t, T(1));
+ A t(T(1));
assert(std::atomic_exchange_explicit(&t, T(2), std::memory_order_seq_cst)
== T(1));
assert(t == T(2));
- volatile A vt;
- std::atomic_init(&vt, T(3));
+ volatile A vt(T(3));
assert(std::atomic_exchange_explicit(&vt, T(4), std::memory_order_seq_cst)
== T(3));
assert(vt == T(4));
//===----------------------------------------------------------------------===//
//
// UNSUPPORTED: libcpp-has-no-threads
-// ... test crashes clang
// <atomic>
void operator()() const {
{
typedef std::atomic<T> A;
- A t;
- std::atomic_init(&t, T(1));
+ A t(T(1));
assert(std::atomic_fetch_add(&t, T(2)) == T(1));
assert(t == T(3));
}
{
typedef std::atomic<T> A;
- volatile A t;
- std::atomic_init(&t, T(1));
+ volatile A t(T(1));
assert(std::atomic_fetch_add(&t, T(2)) == T(1));
assert(t == T(3));
}
{
typedef std::atomic<T> A;
typedef typename std::remove_pointer<T>::type X;
- A t;
- std::atomic_init(&t, T(1*sizeof(X)));
+ A t(T(1 * sizeof(X)));
assert(std::atomic_fetch_add(&t, 2) == T(1*sizeof(X)));
#ifdef _LIBCPP_VERSION // libc++ is nonconforming
std::atomic_fetch_add<X>(&t, 0);
{
typedef std::atomic<T> A;
typedef typename std::remove_pointer<T>::type X;
- volatile A t;
- std::atomic_init(&t, T(1*sizeof(X)));
+ volatile A t(T(1 * sizeof(X)));
assert(std::atomic_fetch_add(&t, 2) == T(1*sizeof(X)));
#ifdef _LIBCPP_VERSION // libc++ is nonconforming
std::atomic_fetch_add<X>(&t, 0);
//===----------------------------------------------------------------------===//
//
// UNSUPPORTED: libcpp-has-no-threads
-// ... test crashes clang
// <atomic>
void operator()() const {
{
typedef std::atomic<T> A;
- A t;
- std::atomic_init(&t, T(1));
+ A t(T(1));
assert(std::atomic_fetch_add_explicit(&t, T(2),
std::memory_order_seq_cst) == T(1));
assert(t == T(3));
}
{
typedef std::atomic<T> A;
- volatile A t;
- std::atomic_init(&t, T(1));
+ volatile A t(T(1));
assert(std::atomic_fetch_add_explicit(&t, T(2),
std::memory_order_seq_cst) == T(1));
assert(t == T(3));
{
typedef std::atomic<T> A;
typedef typename std::remove_pointer<T>::type X;
- A t;
- std::atomic_init(&t, T(1*sizeof(X)));
+ A t(T(1 * sizeof(X)));
assert(std::atomic_fetch_add_explicit(&t, 2,
std::memory_order_seq_cst) == T(1*sizeof(X)));
#ifdef _LIBCPP_VERSION // libc++ is not conforming
{
typedef std::atomic<T> A;
typedef typename std::remove_pointer<T>::type X;
- volatile A t;
- std::atomic_init(&t, T(1*sizeof(X)));
+ volatile A t(T(1 * sizeof(X)));
assert(std::atomic_fetch_add_explicit(&t, 2,
std::memory_order_seq_cst) == T(1*sizeof(X)));
#ifdef _LIBCPP_VERSION // libc++ is not conforming
void operator()() const {
{
typedef std::atomic<T> A;
- A t;
- std::atomic_init(&t, T(1));
+ A t(T(1));
assert(std::atomic_fetch_and(&t, T(2)) == T(1));
assert(t == T(0));
}
{
typedef std::atomic<T> A;
- volatile A t;
- std::atomic_init(&t, T(3));
+ volatile A t(T(3));
assert(std::atomic_fetch_and(&t, T(2)) == T(3));
assert(t == T(2));
}
void operator()() const {
{
typedef std::atomic<T> A;
- A t;
- std::atomic_init(&t, T(1));
+ A t(T(1));
assert(std::atomic_fetch_and_explicit(&t, T(2),
std::memory_order_seq_cst) == T(1));
assert(t == T(0));
}
{
typedef std::atomic<T> A;
- volatile A t;
- std::atomic_init(&t, T(3));
+ volatile A t(T(3));
assert(std::atomic_fetch_and_explicit(&t, T(2),
std::memory_order_seq_cst) == T(3));
assert(t == T(2));
void operator()() const {
{
typedef std::atomic<T> A;
- A t;
- std::atomic_init(&t, T(1));
+ A t(T(1));
assert(std::atomic_fetch_or(&t, T(2)) == T(1));
assert(t == T(3));
}
{
typedef std::atomic<T> A;
- volatile A t;
- std::atomic_init(&t, T(3));
+ volatile A t(T(3));
assert(std::atomic_fetch_or(&t, T(2)) == T(3));
assert(t == T(3));
}
void operator()() const {
{
typedef std::atomic<T> A;
- A t;
- std::atomic_init(&t, T(1));
+ A t(T(1));
assert(std::atomic_fetch_or_explicit(&t, T(2),
std::memory_order_seq_cst) == T(1));
assert(t == T(3));
}
{
typedef std::atomic<T> A;
- volatile A t;
- std::atomic_init(&t, T(3));
+ volatile A t(T(3));
assert(std::atomic_fetch_or_explicit(&t, T(2),
std::memory_order_seq_cst) == T(3));
assert(t == T(3));
//===----------------------------------------------------------------------===//
//
// UNSUPPORTED: libcpp-has-no-threads
-// ... test crashes clang
// <atomic>
void operator()() const {
{
typedef std::atomic<T> A;
- A t;
- std::atomic_init(&t, T(3));
+ A t(T(3));
assert(std::atomic_fetch_sub(&t, T(2)) == T(3));
assert(t == T(1));
}
{
typedef std::atomic<T> A;
- volatile A t;
- std::atomic_init(&t, T(3));
+ volatile A t(T(3));
assert(std::atomic_fetch_sub(&t, T(2)) == T(3));
assert(t == T(1));
}
{
typedef std::atomic<T> A;
typedef typename std::remove_pointer<T>::type X;
- A t;
- std::atomic_init(&t, T(3*sizeof(X)));
+ A t(T(3 * sizeof(X)));
assert(std::atomic_fetch_sub(&t, 2) == T(3*sizeof(X)));
#ifdef _LIBCPP_VERSION // libc++ is nonconforming
std::atomic_fetch_sub<X>(&t, 0);
{
typedef std::atomic<T> A;
typedef typename std::remove_pointer<T>::type X;
- volatile A t;
- std::atomic_init(&t, T(3*sizeof(X)));
+ volatile A t(T(3 * sizeof(X)));
assert(std::atomic_fetch_sub(&t, 2) == T(3*sizeof(X)));
#ifdef _LIBCPP_VERSION // libc++ is nonconforming
std::atomic_fetch_sub<X>(&t, 0);
//===----------------------------------------------------------------------===//
//
// UNSUPPORTED: libcpp-has-no-threads
-// ... test crashes clang
// <atomic>
void operator()() const {
{
typedef std::atomic<T> A;
- A t;
- std::atomic_init(&t, T(3));
+ A t(T(3));
assert(std::atomic_fetch_sub_explicit(&t, T(2),
std::memory_order_seq_cst) == T(3));
assert(t == T(1));
}
{
typedef std::atomic<T> A;
- volatile A t;
- std::atomic_init(&t, T(3));
+ volatile A t(T(3));
assert(std::atomic_fetch_sub_explicit(&t, T(2),
std::memory_order_seq_cst) == T(3));
assert(t == T(1));
{
typedef std::atomic<T> A;
typedef typename std::remove_pointer<T>::type X;
- A t;
- std::atomic_init(&t, T(3*sizeof(X)));
+ A t(T(3 * sizeof(X)));
assert(std::atomic_fetch_sub_explicit(&t, 2,
std::memory_order_seq_cst) == T(3*sizeof(X)));
#ifdef _LIBCPP_VERSION // libc++ is nonconforming
{
typedef std::atomic<T> A;
typedef typename std::remove_pointer<T>::type X;
- volatile A t;
- std::atomic_init(&t, T(3*sizeof(X)));
+ volatile A t(T(3 * sizeof(X)));
assert(std::atomic_fetch_sub_explicit(&t, 2,
std::memory_order_seq_cst) == T(3*sizeof(X)));
#ifdef _LIBCPP_VERSION // libc++ is nonconforming
void operator()() const {
{
typedef std::atomic<T> A;
- A t;
- std::atomic_init(&t, T(1));
+ A t(T(1));
assert(std::atomic_fetch_xor(&t, T(2)) == T(1));
assert(t == T(3));
}
{
typedef std::atomic<T> A;
- volatile A t;
- std::atomic_init(&t, T(3));
+ volatile A t(T(3));
assert(std::atomic_fetch_xor(&t, T(2)) == T(3));
assert(t == T(1));
}
void operator()() const {
{
typedef std::atomic<T> A;
- A t;
- std::atomic_init(&t, T(1));
+ A t(T(1));
assert(std::atomic_fetch_xor_explicit(&t, T(2),
std::memory_order_seq_cst) == T(1));
assert(t == T(3));
}
{
typedef std::atomic<T> A;
- volatile A t;
- std::atomic_init(&t, T(3));
+ volatile A t(T(3));
assert(std::atomic_fetch_xor_explicit(&t, T(2),
std::memory_order_seq_cst) == T(3));
assert(t == T(1));
// UNSUPPORTED: libcpp-has-no-threads
// XFAIL: !non-lockfree-atomics
// ... assertion fails line 36
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
// <atomic>
struct TestFn {
void operator()() const {
typedef std::atomic<T> A;
- A t;
- std::atomic_init(&t, T(1));
+ A t(T(1));
assert(std::atomic_load(&t) == T(1));
- volatile A vt;
- std::atomic_init(&vt, T(2));
+ volatile A vt(T(2));
assert(std::atomic_load(&vt) == T(2));
}
};
struct TestFn {
void operator()() const {
typedef std::atomic<T> A;
- A t;
- std::atomic_init(&t, T(1));
+ A t(T(1));
assert(std::atomic_load_explicit(&t, std::memory_order_seq_cst) == T(1));
- volatile A vt;
- std::atomic_init(&vt, T(2));
+ volatile A vt(T(2));
assert(std::atomic_load_explicit(&vt, std::memory_order_seq_cst) == T(2));
}
};
void operator()() const {
typedef std::atomic<T> A;
- A t;
- std::atomic_init(&t, T(1));
+ A t(T(1));
assert(std::atomic_load(&t) == T(1));
std::atomic_wait(&t, T(0));
std::thread t1 = support::make_test_thread([&](){
std::atomic_wait(&t, T(1));
t1.join();
- volatile A vt;
- std::atomic_init(&vt, T(2));
+ volatile A vt(T(2));
assert(std::atomic_load(&vt) == T(2));
std::atomic_wait(&vt, T(1));
std::thread t2 = support::make_test_thread([&](){
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+//
+// atomic_init
+
+#include <atomic>
+
+void test() {
+ std::atomic<int> a;
+ std::atomic_init(&a, 1); // expected-warning {{'atomic_init<int>' is deprecated}}
+
+ volatile std::atomic<int> b;
+ std::atomic_init(&b, 1); // expected-warning {{'atomic_init<int>' is deprecated}}
+}
# endif
# endif
-# if !defined(_LIBCPP_VERSION)
+# if !defined(_LIBCPP_HAS_NO_THREADS)
# ifndef __cpp_lib_atomic_value_initialization
# error "__cpp_lib_atomic_value_initialization should be defined in c++20"
# endif
# if __cpp_lib_atomic_value_initialization != 201911L
# error "__cpp_lib_atomic_value_initialization should have the value 201911L in c++20"
# endif
-# else // _LIBCPP_VERSION
+# else
# ifdef __cpp_lib_atomic_value_initialization
-# error "__cpp_lib_atomic_value_initialization should not be defined because it is unimplemented in libc++!"
+# error "__cpp_lib_atomic_value_initialization should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
# endif
# endif
# endif
# endif
-# if !defined(_LIBCPP_VERSION)
+# if !defined(_LIBCPP_HAS_NO_THREADS)
# ifndef __cpp_lib_atomic_value_initialization
# error "__cpp_lib_atomic_value_initialization should be defined in c++2b"
# endif
# if __cpp_lib_atomic_value_initialization != 201911L
# error "__cpp_lib_atomic_value_initialization should have the value 201911L in c++2b"
# endif
-# else // _LIBCPP_VERSION
+# else
# ifdef __cpp_lib_atomic_value_initialization
-# error "__cpp_lib_atomic_value_initialization should not be defined because it is unimplemented in libc++!"
+# error "__cpp_lib_atomic_value_initialization should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
# endif
# endif
# endif
# endif
-# if !defined(_LIBCPP_VERSION)
+# if !defined(_LIBCPP_HAS_NO_THREADS)
# ifndef __cpp_lib_atomic_value_initialization
# error "__cpp_lib_atomic_value_initialization should be defined in c++20"
# endif
# if __cpp_lib_atomic_value_initialization != 201911L
# error "__cpp_lib_atomic_value_initialization should have the value 201911L in c++20"
# endif
-# else // _LIBCPP_VERSION
+# else
# ifdef __cpp_lib_atomic_value_initialization
-# error "__cpp_lib_atomic_value_initialization should not be defined because it is unimplemented in libc++!"
+# error "__cpp_lib_atomic_value_initialization should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
# endif
# endif
# endif
# endif
-# if !defined(_LIBCPP_VERSION)
+# if !defined(_LIBCPP_HAS_NO_THREADS)
# ifndef __cpp_lib_atomic_value_initialization
# error "__cpp_lib_atomic_value_initialization should be defined in c++2b"
# endif
# if __cpp_lib_atomic_value_initialization != 201911L
# error "__cpp_lib_atomic_value_initialization should have the value 201911L in c++2b"
# endif
-# else // _LIBCPP_VERSION
+# else
# ifdef __cpp_lib_atomic_value_initialization
-# error "__cpp_lib_atomic_value_initialization should not be defined because it is unimplemented in libc++!"
+# error "__cpp_lib_atomic_value_initialization should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
# endif
# endif
# endif
# endif
-# if !defined(_LIBCPP_VERSION)
+# if !defined(_LIBCPP_HAS_NO_THREADS)
# ifndef __cpp_lib_atomic_value_initialization
# error "__cpp_lib_atomic_value_initialization should be defined in c++20"
# endif
# if __cpp_lib_atomic_value_initialization != 201911L
# error "__cpp_lib_atomic_value_initialization should have the value 201911L in c++20"
# endif
-# else // _LIBCPP_VERSION
+# else
# ifdef __cpp_lib_atomic_value_initialization
-# error "__cpp_lib_atomic_value_initialization should not be defined because it is unimplemented in libc++!"
+# error "__cpp_lib_atomic_value_initialization should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
# endif
# endif
# endif
# endif
-# if !defined(_LIBCPP_VERSION)
+# if !defined(_LIBCPP_HAS_NO_THREADS)
# ifndef __cpp_lib_atomic_value_initialization
# error "__cpp_lib_atomic_value_initialization should be defined in c++2b"
# endif
# if __cpp_lib_atomic_value_initialization != 201911L
# error "__cpp_lib_atomic_value_initialization should have the value 201911L in c++2b"
# endif
-# else // _LIBCPP_VERSION
+# else
# ifdef __cpp_lib_atomic_value_initialization
-# error "__cpp_lib_atomic_value_initialization should not be defined because it is unimplemented in libc++!"
+# error "__cpp_lib_atomic_value_initialization should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
# endif
# endif
"headers": ["atomic", "memory"],
"test_suite_guard": "!defined(_LIBCPP_HAS_NO_THREADS)",
"libcxx_guard": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "unimplemented": True,
}, {
"name": "__cpp_lib_atomic_wait",
"values": { "c++20": 201907 },