16015dd11SMarshall Clow //===----------------------------------------------------------------------===//
26015dd11SMarshall Clow //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66015dd11SMarshall Clow //
76015dd11SMarshall Clow //===----------------------------------------------------------------------===//
86015dd11SMarshall Clow 
9*a7f9895cSLouis Dionne // UNSUPPORTED: no-threads
1031cbe0f2SLouis Dionne // UNSUPPORTED: c++03, c++11, c++14
116015dd11SMarshall Clow 
126015dd11SMarshall Clow // <mutex>
136015dd11SMarshall Clow 
146015dd11SMarshall Clow // template <class ...Mutex> class scoped_lock;
156015dd11SMarshall Clow 
166015dd11SMarshall Clow // explicit scoped_lock(Mutex&...);
176015dd11SMarshall Clow 
186015dd11SMarshall Clow #include <mutex>
196015dd11SMarshall Clow #include "test_macros.h"
206015dd11SMarshall Clow 
216015dd11SMarshall Clow template <class LG>
test_conversion(LG)226015dd11SMarshall Clow void test_conversion(LG) {}
236015dd11SMarshall Clow 
main(int,char **)242df59c50SJF Bastien int main(int, char**)
256015dd11SMarshall Clow {
266015dd11SMarshall Clow     using M = std::mutex;
276015dd11SMarshall Clow     M m0, m1, m2;
286015dd11SMarshall Clow     M n0, n1, n2;
296015dd11SMarshall Clow     {
306015dd11SMarshall Clow         using LG = std::scoped_lock<>;
316015dd11SMarshall Clow         LG lg = {}; // expected-error{{chosen constructor is explicit in copy-initialization}}
326015dd11SMarshall Clow         test_conversion<LG>({}); // expected-error{{no matching function for call}}
336015dd11SMarshall Clow         ((void)lg);
346015dd11SMarshall Clow     }
356015dd11SMarshall Clow     {
366015dd11SMarshall Clow         using LG = std::scoped_lock<M>;
376015dd11SMarshall Clow         LG lg = {m0}; // expected-error{{chosen constructor is explicit in copy-initialization}}
386015dd11SMarshall Clow         test_conversion<LG>({n0}); // expected-error{{no matching function for call}}
396015dd11SMarshall Clow         ((void)lg);
406015dd11SMarshall Clow     }
416015dd11SMarshall Clow     {
426015dd11SMarshall Clow         using LG = std::scoped_lock<M, M>;
436015dd11SMarshall Clow         LG lg = {m0, m1}; // expected-error{{chosen constructor is explicit in copy-initialization}}
446015dd11SMarshall Clow         test_conversion<LG>({n0, n1}); // expected-error{{no matching function for call}}
456015dd11SMarshall Clow         ((void)lg);
466015dd11SMarshall Clow     }
476015dd11SMarshall Clow     {
486015dd11SMarshall Clow         using LG = std::scoped_lock<M, M, M>;
496015dd11SMarshall Clow         LG lg = {m0, m1, m2}; // expected-error{{chosen constructor is explicit in copy-initialization}}
506015dd11SMarshall Clow         test_conversion<LG>({n0, n1, n2}); // expected-error{{no matching function for call}}
516015dd11SMarshall Clow     }
522df59c50SJF Bastien 
532df59c50SJF Bastien   return 0;
546015dd11SMarshall Clow }
55