summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_assign.fail.cpp
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-06-14 03:48:09 +0000
committerEric Fiselier <eric@efcs.ca>2016-06-14 03:48:09 +0000
commit48f35e074e4aca420bd8d58f757f862cd998a9b7 (patch)
tree6ace79c4eaeef6778912d2abe104714103de9f75 /libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_assign.fail.cpp
parent9778a6d811c346eb9cdd8b6c6c28a915e58d1b67 (diff)
downloadbcm5719-llvm-48f35e074e4aca420bd8d58f757f862cd998a9b7.tar.gz
bcm5719-llvm-48f35e074e4aca420bd8d58f757f862cd998a9b7.zip
Implement variadic lock_guard.
Summary: This patch implements the variadic `lock_guard` paper. Making `lock_guard` variadic is a ABI breaking change because the specialization `lock_guard<_Mutex>` mangles differently then when it was the primary template. This change only provides variadic `lock_guard` in ABI V2 or when `_LIBCPP_ABI_VARIADIC_LOCK_GUARD` is defined. Note that in ABI V2 `lock_guard` must always be declared as a variadic template, even in C++03, in order to keep the ABI consistent. For this reason `lock_guard` is forward declared as a variadic template in all standard dialects and therefore depends on variadic templates being provided as an extension in C++03. All supported versions of Clang and GCC provide this extension. Reviewers: mclow.lists Subscribers: K-ballo, mclow.lists, cfe-commits Differential Revision: http://reviews.llvm.org/D21260 llvm-svn: 272634
Diffstat (limited to 'libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_assign.fail.cpp')
-rw-r--r--libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_assign.fail.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_assign.fail.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_assign.fail.cpp
new file mode 100644
index 00000000000..18193e000ed
--- /dev/null
+++ b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_assign.fail.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <mutex>
+
+// template <class ...Mutex> class lock_guard;
+
+// lock_guard& operator=(lock_guard const&) = delete;
+
+#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD
+#include <mutex>
+
+int main()
+{
+ using M = std::mutex;
+ M m0, m1, m2;
+ M om0, om1, om2;
+ {
+ using LG = std::lock_guard<>;
+ LG lg1, lg2;
+ lg1 = lg2; // expected-error{{overload resolution selected deleted operator '='}}
+ }
+ {
+ using LG = std::lock_guard<M, M>;
+ LG lg1(m0, m1);
+ LG lg2(om0, om1);
+ lg1 = lg2; // expected-error{{overload resolution selected deleted operator '='}}
+ }
+ {
+ using LG = std::lock_guard<M, M, M>;
+ LG lg1(m0, m1, m2);
+ LG lg2(om0, om1, om2);
+ lg1 = lg2; // expected-error{{overload resolution selected deleted operator '='}}
+ }
+}
OpenPOWER on IntegriCloud