[libcxx-commits] [libcxx] b108cd7 - [libc++] [test] Rationalize the nodiscard tests for range adaptors.
Arthur O'Dwyer via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Dec 7 11:00:57 PST 2021
Author: Arthur O'Dwyer
Date: 2021-12-07T13:59:42-05:00
New Revision: b108cd7b4539a9314df09aa06142c9ab741a14e3
URL: https://github.com/llvm/llvm-project/commit/b108cd7b4539a9314df09aa06142c9ab741a14e3
DIFF: https://github.com/llvm/llvm-project/commit/b108cd7b4539a9314df09aa06142c9ab741a14e3.diff
LOG: [libc++] [test] Rationalize the nodiscard tests for range adaptors.
Reviewed as part of D115177.
Added:
libcxx/test/libcxx/ranges/range.adaptors/range.reverse/adaptor.nodiscard.verify.cpp
Modified:
libcxx/test/libcxx/ranges/range.adaptors/range.all/all.nodiscard.verify.cpp
libcxx/test/libcxx/ranges/range.adaptors/range.common.view/adaptor.nodiscard.verify.cpp
libcxx/test/libcxx/ranges/range.adaptors/range.transform/adaptor.nodiscard.verify.cpp
Removed:
libcxx/test/std/ranges/range.adaptors/range.reverse/adaptor.nodiscard.verify.cpp
################################################################################
diff --git a/libcxx/test/libcxx/ranges/range.adaptors/range.all/all.nodiscard.verify.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.all/all.nodiscard.verify.cpp
index 6af0e154f051d..c10eb11c015c7 100644
--- a/libcxx/test/libcxx/ranges/range.adaptors/range.all/all.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/ranges/range.adaptors/range.all/all.nodiscard.verify.cpp
@@ -16,10 +16,8 @@
void test() {
int range[] = {1, 2, 3};
- auto f = [](int i) { return i; };
std::views::all(range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
range | std::views::all; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
- std::views::transform(f) | std::views::all; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
- std::views::all | std::views::transform(f); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ std::views::all | std::views::all; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
}
diff --git a/libcxx/test/libcxx/ranges/range.adaptors/range.common.view/adaptor.nodiscard.verify.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.common.view/adaptor.nodiscard.verify.cpp
index 9bb58e1e9920b..8c633399fe814 100644
--- a/libcxx/test/libcxx/ranges/range.adaptors/range.common.view/adaptor.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/ranges/range.adaptors/range.common.view/adaptor.nodiscard.verify.cpp
@@ -10,8 +10,7 @@
// UNSUPPORTED: libcpp-no-concepts
// UNSUPPORTED: libcpp-has-no-incomplete-ranges
-// Test the libc++ extension that std::views::common is marked as [[nodiscard]] to avoid
-// the potential for user mistakenly thinking they're calling an algorithm.
+// Test the libc++ extension that std::views::common is marked as [[nodiscard]].
#include <ranges>
@@ -20,4 +19,5 @@ void test() {
std::views::common(range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
range | std::views::common; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ std::views::all | std::views::common; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
}
diff --git a/libcxx/test/std/ranges/range.adaptors/range.reverse/adaptor.nodiscard.verify.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.reverse/adaptor.nodiscard.verify.cpp
similarity index 77%
rename from libcxx/test/std/ranges/range.adaptors/range.reverse/adaptor.nodiscard.verify.cpp
rename to libcxx/test/libcxx/ranges/range.adaptors/range.reverse/adaptor.nodiscard.verify.cpp
index 1a854446d010f..2c7eadc7040c7 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.reverse/adaptor.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/ranges/range.adaptors/range.reverse/adaptor.nodiscard.verify.cpp
@@ -9,10 +9,8 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17
// UNSUPPORTED: libcpp-no-concepts
// UNSUPPORTED: libcpp-has-no-incomplete-ranges
-// REQUIRES: libc++
-// Test the libc++ extension that std::views::reverse is marked as [[nodiscard]] to avoid
-// the potential for user mistakenly thinking they're calling an algorithm.
+// Test the libc++ extension that std::views::reverse is marked as [[nodiscard]].
#include <ranges>
@@ -21,5 +19,5 @@ void test() {
std::views::reverse(range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
range | std::views::reverse; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
- std::views::reverse | std::views::reverse; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ std::views::all | std::views::reverse; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
}
diff --git a/libcxx/test/libcxx/ranges/range.adaptors/range.transform/adaptor.nodiscard.verify.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.transform/adaptor.nodiscard.verify.cpp
index 4c73eb61b379f..fc642a156950a 100644
--- a/libcxx/test/libcxx/ranges/range.adaptors/range.transform/adaptor.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/ranges/range.adaptors/range.transform/adaptor.nodiscard.verify.cpp
@@ -10,8 +10,7 @@
// UNSUPPORTED: libcpp-no-concepts
// UNSUPPORTED: libcpp-has-no-incomplete-ranges
-// Test the libc++ extension that std::views::transform is marked as [[nodiscard]] to avoid
-// the potential for user mistakenly thinking they're calling an algorithm.
+// Test the libc++ extension that std::views::transform is marked as [[nodiscard]].
#include <ranges>
@@ -22,5 +21,5 @@ void test() {
std::views::transform(f); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
std::views::transform(range, f); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
range | std::views::transform(f); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
- std::views::transform(f) | std::views::transform(f); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ std::views::all | std::views::transform(f); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
}
More information about the libcxx-commits
mailing list