xref: /llvm-project/libcxx/test/std/thread/thread.stoptoken/stopsource/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]] stop_token get_token() const noexcept;
14 // [[nodiscard]] bool stop_possible() const noexcept;
15 // [[nodiscard]] bool stop_requested() const noexcept;
16 // [[nodiscard]] friend bool operator==(const stop_source& lhs, const stop_source& rhs) noexcept;
17 
18 #include <stop_token>
19 
20 void test() {
21   std::stop_source ss;
22   ss.get_token();      // expected-warning {{ignoring return value of function}}
23   ss.stop_requested(); // expected-warning {{ignoring return value of function}}
24   ss.stop_possible();  // expected-warning {{ignoring return value of function}}
25   operator==(ss, ss);  // expected-warning {{ignoring return value of function}}
26 }
27