[libcxx] r242172 - Fix PR24114 - std::atomic for non-Clang is not a literal type
Eric Fiselier
eric at efcs.ca
Tue Jul 14 10:50:29 PDT 2015
Author: ericwf
Date: Tue Jul 14 12:50:27 2015
New Revision: 242172
URL: http://llvm.org/viewvc/llvm-project?rev=242172&view=rev
Log:
Fix PR24114 - std::atomic for non-Clang is not a literal type
Add _LIBCPP_CONSTEXPR to the implementation of __gcc_atomic_t.
Added:
libcxx/trunk/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp
Modified:
libcxx/trunk/include/atomic
Modified: libcxx/trunk/include/atomic
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/atomic?rev=242172&r1=242171&r2=242172&view=diff
==============================================================================
--- libcxx/trunk/include/atomic (original)
+++ libcxx/trunk/include/atomic Tue Jul 14 12:50:27 2015
@@ -554,7 +554,8 @@ namespace __gcc_atomic {
template <typename _Tp>
struct __gcc_atomic_t {
__gcc_atomic_t() _NOEXCEPT {}
- explicit __gcc_atomic_t(_Tp value) _NOEXCEPT : __a_value(value) {}
+ _LIBCPP_CONSTEXPR explicit __gcc_atomic_t(_Tp value) _NOEXCEPT
+ : __a_value(value) {}
_Tp __a_value;
};
#define _Atomic(x) __gcc_atomic::__gcc_atomic_t<x>
Added: libcxx/trunk/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp?rev=242172&view=auto
==============================================================================
--- libcxx/trunk/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp Tue Jul 14 12:50:27 2015
@@ -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>();
+}
More information about the cfe-commits
mailing list