summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/atomics
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2015-07-14 17:50:27 +0000
committerEric Fiselier <eric@efcs.ca>2015-07-14 17:50:27 +0000
commit092c475e250af64e7b9ba459067d43cb71fb6dfd (patch)
tree6c2533a1755a5e2af6c4980ddb02325b121bf585 /libcxx/test/std/atomics
parent6c363ed67a58565623857297657e81db303b09da (diff)
downloadbcm5719-llvm-092c475e250af64e7b9ba459067d43cb71fb6dfd.tar.gz
bcm5719-llvm-092c475e250af64e7b9ba459067d43cb71fb6dfd.zip
Fix PR24114 - std::atomic for non-Clang is not a literal type
Add _LIBCPP_CONSTEXPR to the implementation of __gcc_atomic_t. llvm-svn: 242172
Diffstat (limited to 'libcxx/test/std/atomics')
-rw-r--r--libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp
new file mode 100644
index 00000000000..0eda2338d25
--- /dev/null
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++98, c++03
+
+// <atomic>
+
+// constexpr atomic<T>::atomic(T value)
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+struct UserType {
+ int i;
+
+ UserType() noexcept {}
+ constexpr explicit UserType(int d) noexcept : i(d) {}
+
+ friend bool operator==(const UserType& x, const UserType& y) {
+ return x.i == y.i;
+ }
+};
+
+template <class Tp>
+void test() {
+ typedef std::atomic<Tp> Atomic;
+ static_assert(std::is_literal_type<Atomic>::value, "");
+ constexpr Tp t(42);
+ {
+ constexpr Atomic a(t);
+ assert(a == t);
+ }
+ {
+ constexpr Atomic a{t};
+ assert(a == t);
+ }
+ {
+ constexpr Atomic a = ATOMIC_VAR_INIT(t);
+ assert(a == t);
+ }
+}
+
+
+int main()
+{
+ test<int>();
+ test<UserType>();
+}
OpenPOWER on IntegriCloud