15a83710eSEric Fiselier //===----------------------------------------------------------------------===// 25a83710eSEric Fiselier // 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 65a83710eSEric Fiselier // 75a83710eSEric Fiselier //===----------------------------------------------------------------------===// 85a83710eSEric Fiselier // 9*a7f9895cSLouis Dionne // UNSUPPORTED: no-threads 1031cbe0f2SLouis Dionne // UNSUPPORTED: c++03, c++11 112659663eSLouis Dionne 122659663eSLouis Dionne // dylib support for shared_mutex was added in macosx10.12 13c360553cSLouis Dionne // XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11}} 145a83710eSEric Fiselier 155a83710eSEric Fiselier // <shared_mutex> 165a83710eSEric Fiselier 175a83710eSEric Fiselier // template <class Mutex> class shared_lock; 185a83710eSEric Fiselier 195a83710eSEric Fiselier // shared_lock& operator=(shared_lock&& u); 205a83710eSEric Fiselier 215a83710eSEric Fiselier #include <shared_mutex> 225a83710eSEric Fiselier #include <cassert> 23cc89063bSNico Weber #include "nasty_containers.h" 245a83710eSEric Fiselier 257fc6a556SMarshall Clow #include "test_macros.h" 267fc6a556SMarshall Clow 275a83710eSEric Fiselier main(int,char **)282df59c50SJF Bastienint main(int, char**) 295a83710eSEric Fiselier { 300b54e792SMarshall Clow { 310b54e792SMarshall Clow typedef std::shared_timed_mutex M; 320b54e792SMarshall Clow M m0; 330b54e792SMarshall Clow M m1; 340b54e792SMarshall Clow std::shared_lock<M> lk0(m0); 350b54e792SMarshall Clow std::shared_lock<M> lk1(m1); 365a83710eSEric Fiselier lk1 = std::move(lk0); 370b54e792SMarshall Clow assert(lk1.mutex() == std::addressof(m0)); 385a83710eSEric Fiselier assert(lk1.owns_lock() == true); 395a83710eSEric Fiselier assert(lk0.mutex() == nullptr); 405a83710eSEric Fiselier assert(lk0.owns_lock() == false); 415a83710eSEric Fiselier } 420b54e792SMarshall Clow { 430b54e792SMarshall Clow typedef nasty_mutex M; 440b54e792SMarshall Clow M m0; 450b54e792SMarshall Clow M m1; 460b54e792SMarshall Clow std::shared_lock<M> lk0(m0); 470b54e792SMarshall Clow std::shared_lock<M> lk1(m1); 480b54e792SMarshall Clow lk1 = std::move(lk0); 490b54e792SMarshall Clow assert(lk1.mutex() == std::addressof(m0)); 500b54e792SMarshall Clow assert(lk1.owns_lock() == true); 510b54e792SMarshall Clow assert(lk0.mutex() == nullptr); 520b54e792SMarshall Clow assert(lk0.owns_lock() == false); 530b54e792SMarshall Clow } 542df59c50SJF Bastien 552df59c50SJF Bastien return 0; 560b54e792SMarshall Clow } 57