xref: /llvm-project/libcxx/test/libcxx/diagnostics/set.nodiscard.verify.cpp (revision 83bc7b57714dc2f6b33c188f2b95a0025468ba51)
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
10 
11 // check that <set> functions are marked [[nodiscard]]
12 
13 #include <set>
14 
set_test()15 void set_test() {
16   std::set<int> set;
17   set.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
18 }
19 
multiset_test()20 void multiset_test() {
21   std::multiset<int> multiset;
22   multiset.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
23 }
24