[libcxx] r214406 - Add test cases for creating atomic types for trivially copyable types.
Marshall Clow
mclow.lists at gmail.com
Thu Jul 31 08:20:48 PDT 2014
Author: marshall
Date: Thu Jul 31 10:20:48 2014
New Revision: 214406
URL: http://llvm.org/viewvc/llvm-project?rev=214406&view=rev
Log:
Add test cases for creating atomic types for trivially copyable types.
Added:
libcxx/trunk/test/atomics/atomics.types.generic/trivially_copyable.fail.cpp
libcxx/trunk/test/atomics/atomics.types.generic/trivially_copyable.pass.cpp
Added: libcxx/trunk/test/atomics/atomics.types.generic/trivially_copyable.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/atomics/atomics.types.generic/trivially_copyable.fail.cpp?rev=214406&view=auto
==============================================================================
--- libcxx/trunk/test/atomics/atomics.types.generic/trivially_copyable.fail.cpp (added)
+++ libcxx/trunk/test/atomics/atomics.types.generic/trivially_copyable.fail.cpp Thu Jul 31 10:20:48 2014
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class T>
+// struct atomic
+// {
+// bool is_lock_free() const volatile noexcept;
+// bool is_lock_free() const noexcept;
+// void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
+// void store(T desr, memory_order m = memory_order_seq_cst) noexcept;
+// T load(memory_order m = memory_order_seq_cst) const volatile noexcept;
+// T load(memory_order m = memory_order_seq_cst) const noexcept;
+// operator T() const volatile noexcept;
+// operator T() const noexcept;
+// T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
+// T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept;
+// bool compare_exchange_weak(T& expc, T desr,
+// memory_order s, memory_order f) volatile noexcept;
+// bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) noexcept;
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order s, memory_order f) volatile noexcept;
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order s, memory_order f) noexcept;
+// bool compare_exchange_weak(T& expc, T desr,
+// memory_order m = memory_order_seq_cst) volatile noexcept;
+// bool compare_exchange_weak(T& expc, T desr,
+// memory_order m = memory_order_seq_cst) noexcept;
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order m = memory_order_seq_cst) volatile noexcept;
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order m = memory_order_seq_cst) noexcept;
+//
+// atomic() noexcept = default;
+// constexpr atomic(T desr) noexcept;
+// atomic(const atomic&) = delete;
+// atomic& operator=(const atomic&) = delete;
+// atomic& operator=(const atomic&) volatile = delete;
+// T operator=(T) volatile noexcept;
+// T operator=(T) noexcept;
+// };
+
+#include <atomic>
+#include <new>
+#include <cassert>
+#include <thread> // for thread_id
+#include <chrono> // for nanoseconds
+
+struct NotTriviallyCopyable {
+ NotTriviallyCopyable ( int i ) : i_(i) {}
+ NotTriviallyCopyable ( const NotTriviallyCopyable &rhs) : i_(rhs.i_) {}
+ int i_;
+ };
+
+template <class T>
+void test ( T t ) {
+ std::atomic<T> t0(t);
+ }
+
+int main()
+{
+ test(NotTriviallyCopyable(42));
+}
Added: libcxx/trunk/test/atomics/atomics.types.generic/trivially_copyable.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/atomics/atomics.types.generic/trivially_copyable.pass.cpp?rev=214406&view=auto
==============================================================================
--- libcxx/trunk/test/atomics/atomics.types.generic/trivially_copyable.pass.cpp (added)
+++ libcxx/trunk/test/atomics/atomics.types.generic/trivially_copyable.pass.cpp Thu Jul 31 10:20:48 2014
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class T>
+// struct atomic
+// {
+// bool is_lock_free() const volatile noexcept;
+// bool is_lock_free() const noexcept;
+// void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
+// void store(T desr, memory_order m = memory_order_seq_cst) noexcept;
+// T load(memory_order m = memory_order_seq_cst) const volatile noexcept;
+// T load(memory_order m = memory_order_seq_cst) const noexcept;
+// operator T() const volatile noexcept;
+// operator T() const noexcept;
+// T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
+// T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept;
+// bool compare_exchange_weak(T& expc, T desr,
+// memory_order s, memory_order f) volatile noexcept;
+// bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) noexcept;
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order s, memory_order f) volatile noexcept;
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order s, memory_order f) noexcept;
+// bool compare_exchange_weak(T& expc, T desr,
+// memory_order m = memory_order_seq_cst) volatile noexcept;
+// bool compare_exchange_weak(T& expc, T desr,
+// memory_order m = memory_order_seq_cst) noexcept;
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order m = memory_order_seq_cst) volatile noexcept;
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order m = memory_order_seq_cst) noexcept;
+//
+// atomic() noexcept = default;
+// constexpr atomic(T desr) noexcept;
+// atomic(const atomic&) = delete;
+// atomic& operator=(const atomic&) = delete;
+// atomic& operator=(const atomic&) volatile = delete;
+// T operator=(T) volatile noexcept;
+// T operator=(T) noexcept;
+// };
+
+#include <atomic>
+#include <new>
+#include <cassert>
+#include <thread> // for thread_id
+#include <chrono> // for nanoseconds
+
+struct TriviallyCopyable {
+ TriviallyCopyable ( int i ) : i_(i) {}
+ int i_;
+ };
+
+template <class T>
+void test ( T t ) {
+ std::atomic<T> t0(t);
+ }
+
+int main()
+{
+ test(TriviallyCopyable(42));
+ test(std::this_thread::get_id());
+ test(std::chrono::nanoseconds(2));
+}
More information about the cfe-commits
mailing list