[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / thread / thread.mutex / thread.lock / thread.lock.shared / thread.lock.shared.locking / unlock.pass.cpp
blob4f31a75f68dec22c6b4b5328893a54b8a8c8c7bf
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // UNSUPPORTED: no-threads
10 // UNSUPPORTED: c++03, c++11
12 // <shared_mutex>
14 // template <class Mutex> class shared_lock;
16 // void unlock();
18 #include <cassert>
19 #include <cerrno>
20 #include <shared_mutex>
21 #include <system_error>
23 #include "test_macros.h"
25 bool unlock_called = false;
27 struct mutex
29 void lock_shared() {}
30 void unlock_shared() {unlock_called = true;}
33 mutex m;
35 int main(int, char**)
37 std::shared_lock<mutex> lk(m);
38 lk.unlock();
39 assert(unlock_called == true);
40 assert(lk.owns_lock() == false);
41 #ifndef TEST_HAS_NO_EXCEPTIONS
42 try
44 lk.unlock();
45 assert(false);
47 catch (std::system_error& e)
49 assert(e.code().value() == EPERM);
51 #endif
52 lk.release();
53 #ifndef TEST_HAS_NO_EXCEPTIONS
54 try
56 lk.unlock();
57 assert(false);
59 catch (std::system_error& e)
61 assert(e.code().value() == EPERM);
63 #endif
65 return 0;