File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
libcxx/test/libcxx/memory Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 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
10+
11+ // check that functions are marked [[nodiscard]] as an extension in C++17
12+
13+ // [[nodiscard]] std::make_unique(Args&&...);
14+ // [[nodiscard]] std::make_shared(Args&&...);
15+ //
16+ // [[nodiscard]] std::make_unique(size_t);
17+ // [[nodiscard]] std::make_shared(size_t);
18+ //
19+ // [[nodiscard]] std::make_unique_for_overwrite();
20+ // [[nodiscard]] std::make_shared_for_overwrite();
21+
22+ #include < memory>
23+
24+ void f () {
25+
26+ struct S {
27+ S () = default ;
28+ };
29+
30+ std::make_unique<S>(S{}); // expected-warning {{ignoring return value of function}}
31+ std::make_shared<S>(S{}); // expected-warning {{ignoring return value of function}}
32+
33+ std::make_unique<S[]>(5 ); // expected-warning {{ignoring return value of function}}
34+ std::make_shared<S[]>(5 ); // expected-warning {{ignoring return value of function}}
35+
36+ std::make_unique_for_overwrite<S>(); // expected-warning {{ignoring return value of function}}
37+ std::make_shared_for_overwrite<S>(); // expected-warning {{ignoring return value of function}}
38+
39+ }
You can’t perform that action at this time.
0 commit comments