diff --git a/libcxx/test/libcxx/atomics/atomics.ref/assert.compare_exchange_strong.pass.cpp b/libcxx/test/libcxx/atomics/atomics.ref/assert.compare_exchange_strong.pass.cpp index 066ed1191dd05..92f6a622c329c 100644 --- a/libcxx/test/libcxx/atomics/atomics.ref/assert.compare_exchange_strong.pass.cpp +++ b/libcxx/test/libcxx/atomics/atomics.ref/assert.compare_exchange_strong.pass.cpp @@ -1,3 +1,4 @@ +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libcxx/test/libcxx/atomics/atomics.ref/assert.compare_exchange_weak.pass.cpp b/libcxx/test/libcxx/atomics/atomics.ref/assert.compare_exchange_weak.pass.cpp index e83a143df3f04..3bee003b2143f 100644 --- a/libcxx/test/libcxx/atomics/atomics.ref/assert.compare_exchange_weak.pass.cpp +++ b/libcxx/test/libcxx/atomics/atomics.ref/assert.compare_exchange_weak.pass.cpp @@ -1,3 +1,4 @@ +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libcxx/test/libcxx/atomics/atomics.ref/assert.ctor.pass.cpp b/libcxx/test/libcxx/atomics/atomics.ref/assert.ctor.pass.cpp index ef3705d1db275..3d4700406984c 100644 --- a/libcxx/test/libcxx/atomics/atomics.ref/assert.ctor.pass.cpp +++ b/libcxx/test/libcxx/atomics/atomics.ref/assert.ctor.pass.cpp @@ -1,3 +1,4 @@ +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libcxx/test/libcxx/atomics/atomics.ref/assert.load.pass.cpp b/libcxx/test/libcxx/atomics/atomics.ref/assert.load.pass.cpp index bc92b3dc36225..504d135c4f3d7 100644 --- a/libcxx/test/libcxx/atomics/atomics.ref/assert.load.pass.cpp +++ b/libcxx/test/libcxx/atomics/atomics.ref/assert.load.pass.cpp @@ -1,3 +1,4 @@ +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libcxx/test/libcxx/atomics/atomics.ref/assert.store.pass.cpp b/libcxx/test/libcxx/atomics/atomics.ref/assert.store.pass.cpp index ab0d4a220c94f..1afa42528e14f 100644 --- a/libcxx/test/libcxx/atomics/atomics.ref/assert.store.pass.cpp +++ b/libcxx/test/libcxx/atomics/atomics.ref/assert.store.pass.cpp @@ -1,3 +1,4 @@ +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libcxx/test/libcxx/atomics/atomics.ref/assert.wait.pass.cpp b/libcxx/test/libcxx/atomics/atomics.ref/assert.wait.pass.cpp index dcec2fb628545..39178d2393be2 100644 --- a/libcxx/test/libcxx/atomics/atomics.ref/assert.wait.pass.cpp +++ b/libcxx/test/libcxx/atomics/atomics.ref/assert.wait.pass.cpp @@ -1,3 +1,4 @@ +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libcxx/test/libcxx/atomics/atomics.ref/compare_exchange_strong.verify.cpp b/libcxx/test/libcxx/atomics/atomics.ref/compare_exchange_strong.verify.cpp new file mode 100644 index 0000000000000..427c82dbd0af2 --- /dev/null +++ b/libcxx/test/libcxx/atomics/atomics.ref/compare_exchange_strong.verify.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: diagnose-if-support +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// + +// bool compare_exchange_strong(T& expected, T desired, memory_order success, +// memory_order failure) const noexcept; +// +// Preconditions: failure is memory_order::relaxed, memory_order::consume, +// memory_order::acquire, or memory_order::seq_cst. + +#include + +void test() { + using T = int; + + T x(T(1)); + std::atomic_ref const a(x); + + T expected(T(2)); + T const desired(T(3)); + std::memory_order const success = std::memory_order_relaxed; + // clang-format off + a.compare_exchange_strong(expected, desired, success, std::memory_order_relaxed); + a.compare_exchange_strong(expected, desired, success, std::memory_order_consume); + a.compare_exchange_strong(expected, desired, success, std::memory_order_acquire); + a.compare_exchange_strong(expected, desired, success, std::memory_order_seq_cst); + a.compare_exchange_strong(expected, desired, success, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + a.compare_exchange_strong(expected, desired, success, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // clang-format on +} diff --git a/libcxx/test/libcxx/atomics/atomics.ref/compare_exchange_weak.verify.cpp b/libcxx/test/libcxx/atomics/atomics.ref/compare_exchange_weak.verify.cpp new file mode 100644 index 0000000000000..6a1046074dd26 --- /dev/null +++ b/libcxx/test/libcxx/atomics/atomics.ref/compare_exchange_weak.verify.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: diagnose-if-support +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// + +// bool compare_exchange_weak(T& expected, T desired, memory_order success, +// memory_order failure) const noexcept; +// +// Preconditions: failure is memory_order::relaxed, memory_order::consume, +// memory_order::acquire, or memory_order::seq_cst. + +#include + +void test() { + using T = int; + + T x(T(42)); + std::atomic_ref const a(x); + + T expected(T(2)); + T const desired(T(3)); + std::memory_order const success = std::memory_order_relaxed; + // clang-format off + a.compare_exchange_weak(expected, desired, success, std::memory_order_relaxed); + a.compare_exchange_weak(expected, desired, success, std::memory_order_consume); + a.compare_exchange_weak(expected, desired, success, std::memory_order_acquire); + a.compare_exchange_weak(expected, desired, success, std::memory_order_seq_cst); + a.compare_exchange_weak(expected, desired, success, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + a.compare_exchange_weak(expected, desired, success, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // clang-format on +} diff --git a/libcxx/test/libcxx/atomics/atomics.ref/load.verify.cpp b/libcxx/test/libcxx/atomics/atomics.ref/load.verify.cpp new file mode 100644 index 0000000000000..9fdecb16d9d9b --- /dev/null +++ b/libcxx/test/libcxx/atomics/atomics.ref/load.verify.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: diagnose-if-support +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// + +// T load(memory_order order = memory_order::seq_cst) const noexcept; +// +// Preconditions: order is memory_order::relaxed, memory_order::consume, memory_order::acquire, or memory_order::seq_cst. + +#include + +void test() { + using T = int; + + T x(T(1)); + std::atomic_ref const a(x); + + // clang-format off + (void)a.load(std::memory_order_relaxed); + (void)a.load(std::memory_order_consume); + (void)a.load(std::memory_order_acquire); + (void)a.load(std::memory_order_seq_cst); + (void)a.load(std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + (void)a.load(std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // clang-format on +} diff --git a/libcxx/test/libcxx/atomics/atomics.ref/store.verify.cpp b/libcxx/test/libcxx/atomics/atomics.ref/store.verify.cpp new file mode 100644 index 0000000000000..0be4e5ebfa2cc --- /dev/null +++ b/libcxx/test/libcxx/atomics/atomics.ref/store.verify.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: diagnose-if-support +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// + +// void store(T desired, memory_order order = memory_order::seq_cst) const noexcept; +// +// Preconditions: order is memory_order::relaxed, memory_order::release, or memory_order::seq_cst. + +#include + +void test() { + using T = int; + + T x(T(1)); + std::atomic_ref const a(x); + + T const desired(T(2)); + + // clang-format off + a.store(desired, std::memory_order_relaxed); + a.store(desired, std::memory_order_release); + a.store(desired, std::memory_order_seq_cst); + a.store(desired, std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}} + a.store(desired, std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}} + a.store(desired, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // clang-format on +} diff --git a/libcxx/test/libcxx/atomics/atomics.ref/wait.verify.cpp b/libcxx/test/libcxx/atomics/atomics.ref/wait.verify.cpp new file mode 100644 index 0000000000000..718e716ebdb32 --- /dev/null +++ b/libcxx/test/libcxx/atomics/atomics.ref/wait.verify.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: diagnose-if-support +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// + +// void wait(T old, memory_order order = memory_order::seq_cst) const noexcept; +// +// Preconditions: order is memory_order::relaxed, memory_order::consume, memory_order::acquire, or memory_order::seq_cst. + +#include + +void test() { + using T = int; + + T x(T(1)); + std::atomic_ref const a(x); + + T const old(T(2)); + + // clang-format off + a.wait(old, std::memory_order_relaxed); + a.wait(old, std::memory_order_consume); + a.wait(old, std::memory_order_acquire); + a.wait(old, std::memory_order_seq_cst); + a.wait(old, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + a.wait(old, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // clang-format on +}