Skip to content

Commit b108cd7

Browse files
committed
[libc++] [test] Rationalize the nodiscard tests for range adaptors.
Reviewed as part of D115177.
1 parent bd0c0e5 commit b108cd7

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

libcxx/test/libcxx/ranges/range.adaptors/range.all/all.nodiscard.verify.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616

1717
void test() {
1818
int range[] = {1, 2, 3};
19-
auto f = [](int i) { return i; };
2019

2120
std::views::all(range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
2221
range | std::views::all; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
23-
std::views::transform(f) | std::views::all; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
24-
std::views::all | std::views::transform(f); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
22+
std::views::all | std::views::all; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
2523
}

libcxx/test/libcxx/ranges/range.adaptors/range.common.view/adaptor.nodiscard.verify.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
// UNSUPPORTED: libcpp-no-concepts
1111
// UNSUPPORTED: libcpp-has-no-incomplete-ranges
1212

13-
// Test the libc++ extension that std::views::common is marked as [[nodiscard]] to avoid
14-
// the potential for user mistakenly thinking they're calling an algorithm.
13+
// Test the libc++ extension that std::views::common is marked as [[nodiscard]].
1514

1615
#include <ranges>
1716

@@ -20,4 +19,5 @@ void test() {
2019

2120
std::views::common(range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
2221
range | std::views::common; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
22+
std::views::all | std::views::common; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
2323
}

libcxx/test/std/ranges/range.adaptors/range.reverse/adaptor.nodiscard.verify.cpp renamed to libcxx/test/libcxx/ranges/range.adaptors/range.reverse/adaptor.nodiscard.verify.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99
// UNSUPPORTED: c++03, c++11, c++14, c++17
1010
// UNSUPPORTED: libcpp-no-concepts
1111
// UNSUPPORTED: libcpp-has-no-incomplete-ranges
12-
// REQUIRES: libc++
1312

14-
// Test the libc++ extension that std::views::reverse is marked as [[nodiscard]] to avoid
15-
// the potential for user mistakenly thinking they're calling an algorithm.
13+
// Test the libc++ extension that std::views::reverse is marked as [[nodiscard]].
1614

1715
#include <ranges>
1816

@@ -21,5 +19,5 @@ void test() {
2119

2220
std::views::reverse(range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
2321
range | std::views::reverse; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
24-
std::views::reverse | std::views::reverse; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
22+
std::views::all | std::views::reverse; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
2523
}

libcxx/test/libcxx/ranges/range.adaptors/range.transform/adaptor.nodiscard.verify.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
// UNSUPPORTED: libcpp-no-concepts
1111
// UNSUPPORTED: libcpp-has-no-incomplete-ranges
1212

13-
// Test the libc++ extension that std::views::transform is marked as [[nodiscard]] to avoid
14-
// the potential for user mistakenly thinking they're calling an algorithm.
13+
// Test the libc++ extension that std::views::transform is marked as [[nodiscard]].
1514

1615
#include <ranges>
1716

@@ -22,5 +21,5 @@ void test() {
2221
std::views::transform(f); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
2322
std::views::transform(range, f); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
2423
range | std::views::transform(f); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
25-
std::views::transform(f) | std::views::transform(f); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
24+
std::views::all | std::views::transform(f); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
2625
}

0 commit comments

Comments
 (0)