Howard Hinnant | 4777bf2 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Jonathan Roelofs | 8d86b2e | 2014-09-05 19:45:05 +0000 | [diff] [blame] | 9 | // |
| 10 | // UNSUPPORTED: libcpp-has-no-threads |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 11 | // ... assertion fails line 31 |
Howard Hinnant | 4777bf2 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 12 | |
| 13 | // <atomic> |
| 14 | |
| 15 | // template <class T> |
| 16 | // void |
| 17 | // atomic_store_explicit(volatile atomic<T>* obj, T desr, memory_order m); |
| 18 | // |
| 19 | // template <class T> |
| 20 | // void |
| 21 | // atomic_store_explicit(atomic<T>* obj, T desr, memory_order m); |
| 22 | |
| 23 | #include <atomic> |
Richard Smith | 9efdc0b | 2012-04-19 00:50:47 +0000 | [diff] [blame] | 24 | #include <type_traits> |
Howard Hinnant | 4777bf2 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 25 | #include <cassert> |
| 26 | |
| 27 | template <class T> |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 28 | void |
| 29 | test() |
| 30 | { |
Howard Hinnant | 4777bf2 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 31 | typedef std::atomic<T> A; |
| 32 | A t; |
| 33 | std::atomic_store_explicit(&t, T(1), std::memory_order_seq_cst); |
| 34 | assert(t == T(1)); |
| 35 | volatile A vt; |
| 36 | std::atomic_store_explicit(&vt, T(2), std::memory_order_seq_cst); |
| 37 | assert(vt == T(2)); |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 38 | } |
Howard Hinnant | 4777bf2 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 39 | |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 40 | struct A |
| 41 | { |
| 42 | int i; |
| 43 | |
| 44 | explicit A(int d = 0) noexcept {i=d;} |
| 45 | |
| 46 | friend bool operator==(const A& x, const A& y) |
| 47 | {return x.i == y.i;} |
| 48 | }; |
Eric Fiselier | 00f4a49 | 2015-08-19 17:21:46 +0000 | [diff] [blame] | 49 | |
Howard Hinnant | 4777bf2 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 50 | int main() |
| 51 | { |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 52 | test<A>(); |
| 53 | test<char>(); |
| 54 | test<signed char>(); |
| 55 | test<unsigned char>(); |
| 56 | test<short>(); |
| 57 | test<unsigned short>(); |
| 58 | test<int>(); |
| 59 | test<unsigned int>(); |
| 60 | test<long>(); |
| 61 | test<unsigned long>(); |
| 62 | test<long long>(); |
| 63 | test<unsigned long long>(); |
| 64 | test<wchar_t>(); |
| 65 | #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS |
| 66 | test<char16_t>(); |
| 67 | test<char32_t>(); |
| 68 | #endif // _LIBCPP_HAS_NO_UNICODE_CHARS |
| 69 | test<int*>(); |
| 70 | test<const int*>(); |
Howard Hinnant | 4777bf2 | 2010-12-06 23:10:08 +0000 | [diff] [blame] | 71 | } |