[libcxx-commits] [libcxx] 0414cf0 - Move nondiscard tests of ranges::contains() to the right place. (#76887)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jan 4 14:25:18 PST 2024
Author: ZijunZhaoCCK
Date: 2024-01-04T14:25:13-08:00
New Revision: 0414cf09f02239254c449b7c5a37428fecb943f7
URL: https://github.com/llvm/llvm-project/commit/0414cf09f02239254c449b7c5a37428fecb943f7
DIFF: https://github.com/llvm/llvm-project/commit/0414cf09f02239254c449b7c5a37428fecb943f7.diff
LOG: Move nondiscard tests of ranges::contains() to the right place. (#76887)
nondiscard tests of ranges::contains() should be in
ranges.nodiscard_extensions files rather than nodiscard_extensions files
Added:
Modified:
libcxx/test/libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp
libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp
libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp
libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp
Removed:
################################################################################
diff --git a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp
index 641fcd9233bc2e..e9fab0c75a98e9 100644
--- a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp
+++ b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp
@@ -45,9 +45,6 @@ void test_algorithms() {
#if TEST_STD_VER >= 17
std::clamp(2, 1, 3);
std::clamp(2, 3, 1, std::greater<int>());
-#endif
-#if TEST_STD_VER >= 23
- std::ranges::contains(arr, arr + 1, 1);
#endif
std::count_if(std::begin(arr), std::end(arr), P());
std::count(std::begin(arr), std::end(arr), 1);
diff --git a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp
index 1e3f537f01ed6e..d7a26d99e52233 100644
--- a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp
@@ -60,11 +60,6 @@ void test_algorithms() {
std::clamp(2, 1, 3, std::greater<int>());
#endif
-#if TEST_STD_VER >= 23
- // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
- std::ranges::contains(arr, arr + 1, 1);
-#endif
-
// expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
std::count_if(std::begin(arr), std::end(arr), P());
diff --git a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp
index 7e2d64b8c9b618..19e07b83079c78 100644
--- a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp
+++ b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp
@@ -15,6 +15,8 @@
#include <algorithm>
+#include "test_macros.h"
+
void test() {
int range[1];
int* iter = range;
@@ -28,6 +30,10 @@ void test() {
std::ranges::binary_search(range, 1);
std::ranges::binary_search(iter, iter, 1);
std::ranges::clamp(1, 2, 3);
+#if TEST_STD_VER >= 23
+ std::ranges::contains(range, 1);
+ std::ranges::contains(iter, iter, 1);
+#endif
std::ranges::count_if(range, pred);
std::ranges::count_if(iter, iter, pred);
std::ranges::count(range, 1);
diff --git a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp
index f0a0e4889a7603..5e45ad086cbd08 100644
--- a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp
@@ -91,6 +91,10 @@ void test() {
std::ranges::upper_bound(iter, iter, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
#if TEST_STD_VER >= 23
+ std::ranges::contains(range, 1);
+ // expected-warning at -1{{ignoring return value of function declared with 'nodiscard' attribute}}
+ std::ranges::contains(iter, iter, 1);
+ // expected-warning at -1{{ignoring return value of function declared with 'nodiscard' attribute}}
std::ranges::fold_left(range, 0, std::plus());
// expected-warning at -1{{ignoring return value of function declared with 'nodiscard' attribute}}
std::ranges::fold_left(iter, iter, 0, std::plus());
More information about the libcxx-commits
mailing list