xref: /llvm-project/libcxx/test/std/thread/thread.jthread/nodiscard.verify.cpp (revision 121ed5c1985356436d0040dbe81bca26992b1fae)
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, c++14, c++17
11 // XFAIL: availability-synchronization_library-missing
12 
13 // [[nodiscard]] bool joinable() const noexcept;
14 // [[nodiscard]] id get_id() const noexcept;
15 // [[nodiscard]] native_handle_type native_handle();
16 // [[nodiscard]] stop_source get_stop_source() noexcept;
17 // [[nodiscard]] stop_token get_stop_token() const noexcept;
18 // [[nodiscard]] static unsigned int hardware_concurrency() noexcept;
19 
20 #include <thread>
21 
22 void test() {
23   std::jthread jt;
24   jt.joinable();             // expected-warning {{ignoring return value of function}}
25   jt.get_id();               // expected-warning {{ignoring return value of function}}
26   jt.native_handle();        // expected-warning {{ignoring return value of function}}
27   jt.get_stop_source();      // expected-warning {{ignoring return value of function}}
28   jt.get_stop_token();       // expected-warning {{ignoring return value of function}}
29   jt.hardware_concurrency(); // expected-warning {{ignoring return value of function}}
30 }
31