• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // UNSUPPORTED: libcpp-has-no-threads
11 // UNSUPPORTED: c++98, c++03
12 
13 // <mutex>
14 
15 // template <class ...Mutex> class lock_guard;
16 
17 // explicit lock_guard(Mutex&...);
18 
19 // MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD
20 #define _LIBCPP_ABI_VARIADIC_LOCK_GUARD
21 #include <mutex>
22 
23 template <class LG>
test_conversion(LG)24 void test_conversion(LG) {}
25 
main()26 int main()
27 {
28     using M = std::mutex;
29     M m0, m1, m2;
30     M n0, n1, n2;
31     {
32         using LG = std::lock_guard<>;
33         LG lg = {}; // expected-error{{chosen constructor is explicit in copy-initialization}}
34         test_conversion<LG>({}); // expected-error{{no matching function for call}}
35         ((void)lg);
36     }
37     {
38         using LG = std::lock_guard<M, M>;
39         LG lg = {m0, m1}; // expected-error{{chosen constructor is explicit in copy-initialization}}
40         test_conversion<LG>({n0, n1}); // expected-error{{no matching function for call}}
41         ((void)lg);
42     }
43     {
44         using LG = std::lock_guard<M, M, M>;
45         LG lg = {m0, m1, m2}; // expected-error{{chosen constructor is explicit in copy-initialization}}
46         test_conversion<LG>({n0, n1, n2}); // expected-error{{no matching function for call}}
47     }
48 }
49