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: c++03, c++11, c++14, c++17
10 
11 // Make sure the various node handles mark their .empty() method with
12 // [[nodiscard]] starting with C++20
13 
14 #include <map>
15 #include <set>
16 #include <unordered_map>
17 #include <unordered_set>
18 
test()19 void test() {
20     {
21         std::map<int, int>::node_type node;
22         node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
23     }
24     {
25         std::multimap<int, int>::node_type node;
26         node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
27     }
28     {
29         std::set<int> node;
30         node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
31     }
32     {
33         std::multiset<int> node;
34         node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
35     }
36     {
37         std::unordered_map<int, int> node;
38         node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
39     }
40     {
41         std::unordered_multimap<int, int> node;
42         node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
43     }
44     {
45         std::unordered_set<int> node;
46         node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
47     }
48     {
49         std::unordered_multiset<int> node;
50         node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
51     }
52 }
53