From 092c475e250af64e7b9ba459067d43cb71fb6dfd Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Tue, 14 Jul 2015 17:50:27 +0000 Subject: 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 --- .../atomics.types.operations.req/ctor.pass.cpp | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp (limited to 'libcxx/test/std/atomics') 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 + +// + +// constexpr atomic::atomic(T value) + +#include +#include +#include + +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 +void test() { + typedef std::atomic Atomic; + static_assert(std::is_literal_type::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(); + test(); +} -- cgit v1.2.3