diff --git a/libcxx/include/atomic b/libcxx/include/atomic --- a/libcxx/include/atomic +++ b/libcxx/include/atomic @@ -1681,16 +1681,10 @@ #ifndef _LIBCPP_CXX03_LANG __atomic_base(const __atomic_base&) = delete; - __atomic_base& operator=(const __atomic_base&) = delete; - __atomic_base& operator=(const __atomic_base&) volatile = delete; #else private: _LIBCPP_INLINE_VISIBILITY __atomic_base(const __atomic_base&); - _LIBCPP_INLINE_VISIBILITY - __atomic_base& operator=(const __atomic_base&); - _LIBCPP_INLINE_VISIBILITY - __atomic_base& operator=(const __atomic_base&) volatile; #endif }; @@ -1800,6 +1794,9 @@ _LIBCPP_INLINE_VISIBILITY _Tp operator=(_Tp __d) _NOEXCEPT {__base::store(__d); return __d;} + + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; }; // atomic @@ -1862,6 +1859,9 @@ _Tp* operator-=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;} _LIBCPP_INLINE_VISIBILITY _Tp* operator-=(ptrdiff_t __op) _NOEXCEPT {return fetch_sub(__op) - __op;} + + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; }; // atomic_is_lock_free diff --git a/libcxx/test/std/atomics/atomics.types.generic/copy_semantics_traits.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/copy_semantics_traits.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/atomics/atomics.types.generic/copy_semantics_traits.pass.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// UNSUPPORTED: libcpp-has-no-threads + +// + +// template +// struct atomic +// { +// atomic(const atomic&) = delete; +// atomic& operator=(const atomic&) = delete; +// atomic& operator=(const atomic&) volatile = delete; +// }; + +// template +// struct atomic +// { +// atomic(const atomic&) = delete; +// atomic& operator=(const atomic&) = delete; +// atomic& operator=(const atomic&) volatile = delete; +// }; + +#include + +#include + +template +using is_volatile_copy_assignable = std::is_assignable; + +int main(int, char**) +{ + static_assert(!std::is_copy_constructible >::value, ""); + static_assert(!std::is_copy_assignable >::value, ""); + static_assert(!is_volatile_copy_assignable >::value, ""); + static_assert(!std::is_copy_constructible >::value, ""); + static_assert(!std::is_copy_assignable >::value, ""); + static_assert(!is_volatile_copy_assignable >::value, ""); + + return 0; +} diff --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/copy.assign.ptr.volatile.verify.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/copy.assign.ptr.volatile.verify.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/copy.assign.ptr.volatile.verify.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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: libcpp-has-no-threads + +// + +// std::atomic + +// atomic& operator=( const atomic& ) volatile = delete; + +#include + +int main(int, char**) +{ + volatile std::atomic obj1; + std::atomic obj2; + obj1 = obj2; // expected-error {{overload resolution selected deleted operator '='}} +} diff --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/copy.assign.volatile.verify.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/copy.assign.volatile.verify.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/copy.assign.volatile.verify.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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: libcpp-has-no-threads + +// + +// std::atomic + +// atomic& operator=( const atomic& ) volatile = delete; + +#include + +int main(int, char**) +{ + volatile std::atomic obj1; + std::atomic obj2; + obj1 = obj2; // expected-error {{overload resolution selected deleted operator '='}} +}