[libcxx-commits] [libcxx] Move nondiscard tests of ranges::contains() to the right place. (PR #76887)

via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jan 3 18:30:03 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: None (ZijunZhaoCCK)

<details>
<summary>Changes</summary>

nondiscard tests of ranges::contains() should be in ranges.nodiscard_extensions files  rather than nodiscard_extensions files

---
Full diff: https://github.com/llvm/llvm-project/pull/76887.diff


4 Files Affected:

- (modified) libcxx/test/libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp (-3) 
- (modified) libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp (-5) 
- (modified) libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp (+2) 
- (modified) libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp (+4) 


``````````diff
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..9dc9c46ad89090 100644
--- a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp
+++ b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp
@@ -28,6 +28,8 @@ void test() {
   std::ranges::binary_search(range, 1);
   std::ranges::binary_search(iter, iter, 1);
   std::ranges::clamp(1, 2, 3);
+  std::ranges::contains(range, 1);
+  std::ranges::contains(iter, iter, 1);
   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());

``````````

</details>


https://github.com/llvm/llvm-project/pull/76887


More information about the libcxx-commits mailing list