Skip to content

Commit 679fbf0

Browse files
committed
Lengthen test
1 parent 21b948f commit 679fbf0

File tree

1 file changed

+37
-28
lines changed

1 file changed

+37
-28
lines changed

libcxx/test/libcxx/diagnostics/array.nodiscard.verify.cpp

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,53 @@
1515

1616
#include <test_macros.h>
1717

18-
template <typename ArrT>
18+
template <std::size_t N>
1919
void test_members() {
20-
ArrT a{};
20+
std::array<int, N> a;
21+
const std::array<int, N> ca{};
2122

22-
a.begin(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
23-
a.end(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
24-
a.rbegin(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
25-
a.rend(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
26-
a.cbegin(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
27-
a.cend(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
28-
a.crbegin(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
29-
a.crend(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
23+
a.begin(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
24+
ca.begin(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
25+
a.end(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
26+
ca.end(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
27+
a.rbegin(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
28+
ca.rbegin(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
29+
a.rend(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
30+
ca.rend(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
31+
a.cbegin(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
32+
ca.cbegin(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
33+
a.cend(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
34+
ca.cend(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
35+
a.crbegin(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
36+
ca.crbegin(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
37+
a.crend(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
38+
ca.crend(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
3039

31-
a.size(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
32-
a.max_size(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
33-
a.empty(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
40+
a.size(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
41+
a.max_size(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
42+
a.empty(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
3443

35-
a[0]; // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
36-
a.at(0); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
44+
a[0]; // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
45+
ca[0]; // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
46+
a.at(0); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
47+
ca.at(0); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
3748

38-
a.front(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
39-
a.back(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
49+
a.front(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
50+
ca.front(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
51+
a.back(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
52+
ca.back(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
4053

41-
a.data(); // expected-warning 4 {{ignoring return value of function declared with 'nodiscard' attribute}}
54+
a.data(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
55+
ca.data(); // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
4256
}
4357

4458
template <typename ArrT>
4559
void test_get() {
46-
ArrT a{};
60+
std::array<int> a{};
4761

48-
// expected-warning@+1 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
62+
// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
4963
std::get<0>(a);
50-
// expected-warning@+1 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
64+
// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
5165
std::get<0>(std::move(a));
5266
}
5367

@@ -61,11 +75,6 @@ void test_to_array() {
6175
#endif
6276

6377
void test() {
64-
test_members<std::array<int, 82>>();
65-
test_members<const std::array<int, 82>>();
66-
test_members<std::array<int, 0>>();
67-
test_members<const std::array<int, 0>>();
68-
69-
test_get<std::array<int, 82>>();
70-
test_get<const std::array<int, 82>>();
78+
test_members<0>();
79+
test_members<82>();
7180
}

0 commit comments

Comments
 (0)