summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/thread
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/thread')
-rw-r--r--libcxx/test/std/thread/thread.mutex/thread.lock/types.fail.cpp34
-rw-r--r--libcxx/test/std/thread/thread.mutex/thread.lock/types.pass.cpp9
2 files changed, 38 insertions, 5 deletions
diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock/types.fail.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock/types.fail.cpp
new file mode 100644
index 00000000000..4542c04c297
--- /dev/null
+++ b/libcxx/test/std/thread/thread.mutex/thread.lock/types.fail.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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: c++98, c++03
+// UNSUPPORTED: libcpp-has-no-threads
+
+// Before GCC 6, aggregate initialization kicks in.
+// See https://stackoverflow.com/q/41799015/627587.
+// UNSUPPORTED: gcc-5
+
+// <mutex>
+
+// struct defer_lock_t { explicit defer_lock_t() = default; };
+// struct try_to_lock_t { explicit try_to_lock_t() = default; };
+// struct adopt_lock_t { explicit adopt_lock_t() = default; };
+
+// This test checks for LWG 2510.
+
+#include <mutex>
+
+
+std::defer_lock_t f1() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+std::try_to_lock_t f2() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+std::adopt_lock_t f3() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
+
+int main(int, char**) {
+ return 0;
+}
diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock/types.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock/types.pass.cpp
index 84c39baafa6..c03ca4622aa 100644
--- a/libcxx/test/std/thread/thread.mutex/thread.lock/types.pass.cpp
+++ b/libcxx/test/std/thread/thread.mutex/thread.lock/types.pass.cpp
@@ -10,16 +10,15 @@
// <mutex>
-// struct defer_lock_t {};
-// struct try_to_lock_t {};
-// struct adopt_lock_t {};
+// struct defer_lock_t { explicit defer_lock_t() = default; };
+// struct try_to_lock_t { explicit try_to_lock_t() = default; };
+// struct adopt_lock_t { explicit adopt_lock_t() = default; };
//
// constexpr defer_lock_t defer_lock{};
// constexpr try_to_lock_t try_to_lock{};
// constexpr adopt_lock_t adopt_lock{};
#include <mutex>
-#include <type_traits>
#include "test_macros.h"
@@ -33,5 +32,5 @@ int main(int, char**)
T2 t2 = std::try_to_lock; ((void)t2);
T3 t3 = std::adopt_lock; ((void)t3);
- return 0;
+ return 0;
}
OpenPOWER on IntegriCloud