File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
libcxx/test/libcxx/utilities/expected/expected.expected Expand file tree Collapse file tree 1 file changed +31
-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, c++17
10+
11+ // <expected>
12+
13+ // Test that std::expected generates [[nodiscard]] warnings
14+
15+ #include < expected>
16+
17+ std::expected<int , int > returns_expected () {
18+ return std::expected<int , int >(5 );
19+ }
20+
21+ std::expected<void , int > returns_expected_void () {
22+ return std::expected<void , int >();
23+ }
24+
25+ void test () {
26+ // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
27+ returns_expected ();
28+
29+ // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
30+ returns_expected_void ();
31+ }
You can’t perform that action at this time.
0 commit comments