[libcxx-commits] [PATCH] D72240: Implement C++20 std::atomic_ref and test
Benjamin Trapani via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Nov 26 14:31:45 PST 2020
BenjaminTrapani updated this revision to Diff 307931.
BenjaminTrapani added a comment.
Remove C11 atomic path from atomic header. Update tests to check for specific errors. Other style fixes.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72240/new/
https://reviews.llvm.org/D72240
Files:
libcxx/test/std/atomics/atomics.types.generic/assign_to_atomic_ref_deleted.fail.cpp
libcxx/test/std/atomics/atomics.types.generic/trivially_copyable_ref.fail.cpp
Index: libcxx/test/std/atomics/atomics.types.generic/trivially_copyable_ref.fail.cpp
===================================================================
--- libcxx/test/std/atomics/atomics.types.generic/trivially_copyable_ref.fail.cpp
+++ libcxx/test/std/atomics/atomics.types.generic/trivially_copyable_ref.fail.cpp
@@ -45,9 +45,10 @@
int i_;
};
-template <class T, class>
+template <class T>
void test(T t) {
- std::atomic_ref<T> t0(t);
+ std::atomic_ref<T> t0(
+ t); // expected-error at atomic:* {{static_assert failed due to requirement 'is_trivially_copyable<NotTriviallyCopyable>::value' "std::atomic_ref<_Tp> requires that '_Tp' be a trivially copyable type"}}
}
int main(int, char**) {
Index: libcxx/test/std/atomics/atomics.types.generic/assign_to_atomic_ref_deleted.fail.cpp
===================================================================
--- libcxx/test/std/atomics/atomics.types.generic/assign_to_atomic_ref_deleted.fail.cpp
+++ libcxx/test/std/atomics/atomics.types.generic/assign_to_atomic_ref_deleted.fail.cpp
@@ -13,7 +13,12 @@
// {
// static constexpr bool is_always_lock_free;
// static constexpr size_t required_alignment;
-
+//
+// explicit atomic_ref(T& obj) noexcept;
+// atomic_ref(const atomic_ref&) noexcept;
+// T operator=(T desired) const noexcept;
+// atomic_ref& operator=(const atomic_ref&) = delete;
+//
// bool is_lock_free() const noexcept;
// void store(T desr, memory_order m = memory_order_seq_cst) const noexcept;
// T load(memory_order m = memory_order_seq_cst) const noexcept;
@@ -26,11 +31,6 @@
// memory_order m = memory_order_seq_cst) const noexcept;
// bool compare_exchange_strong(T& expc, T desr,
// memory_order m = memory_order_seq_cst) const noexcept;
-
-// explicit atomic_ref(T& obj) noexcept;
-// atomic_ref(const atomic_ref&) noexcept;
-// T operator=(T desired) const noexcept;
-// atomic_ref& operator=(const atomic_ref&) = delete;
// };
#include <atomic>
@@ -41,7 +41,8 @@
int val = 1;
std::atomic_ref<int> t0(val);
std::atomic_ref<int> t1(val);
- t0 = t1;
+ t0 =
+ t1; // expected-error {{object of type 'std::atomic_ref<int>' cannot be assigned because its copy assignment operator is implicitly deleted}}
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72240.307931.patch
Type: text/x-patch
Size: 2351 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20201126/2e8bdbfd/attachment.bin>
More information about the libcxx-commits
mailing list