[libcxx-commits] [libcxx] a383c1a - [libc++][array] Test `[[nodicard]]` with `array::const_iterator` (#202070)

via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jun 6 23:21:57 PDT 2026


Author: Hristo Hristov
Date: 2026-06-07T09:21:53+03:00
New Revision: a383c1ae2e259c0bea62b7eeb4bae490651c9c7f

URL: https://github.com/llvm/llvm-project/commit/a383c1ae2e259c0bea62b7eeb4bae490651c9c7f
DIFF: https://github.com/llvm/llvm-project/commit/a383c1ae2e259c0bea62b7eeb4bae490651c9c7f.diff

LOG: [libc++][array] Test `[[nodicard]]`  with `array::const_iterator` (#202070)

Added tests with `array::const_iterator` for completeness.

Implemented in https://github.com/llvm/llvm-project/pull/198492

Towards #172124

Added: 
    

Modified: 
    libcxx/test/libcxx/containers/sequences/array/nodiscard.iterator.verify.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/libcxx/containers/sequences/array/nodiscard.iterator.verify.cpp b/libcxx/test/libcxx/containers/sequences/array/nodiscard.iterator.verify.cpp
index a3ae77ae415f6..d2f4921a96ca2 100644
--- a/libcxx/test/libcxx/containers/sequences/array/nodiscard.iterator.verify.cpp
+++ b/libcxx/test/libcxx/containers/sequences/array/nodiscard.iterator.verify.cpp
@@ -17,23 +17,36 @@
 void test() {
   typedef std::array<int, 94> Container;
   Container c;
-  Container::iterator it = c.begin();
+  Container::iterator it        = c.begin();
+  Container::const_iterator cit = c.cbegin();
 
   // expected-warning-re at +1 {{{{(ignoring return value of function declared with 'nodiscard' attribute|expression result unused)}}}}
   *it;
+  // expected-warning-re at +1 {{{{(ignoring return value of function declared with 'nodiscard' attribute|expression result unused)}}}}
+  *cit;
 
   // expected-warning-re at +1 {{{{(ignoring return value of function declared with 'nodiscard' attribute|expression result unused)}}}}
   it[0];
+  // expected-warning-re at +1 {{{{(ignoring return value of function declared with 'nodiscard' attribute|expression result unused)}}}}
+  cit[0];
 
   // expected-warning-re at +1 {{{{(ignoring return value of function declared with 'nodiscard' attribute|expression result unused)}}}}
   it + 1;
+  // expected-warning-re at +1 {{{{(ignoring return value of function declared with 'nodiscard' attribute|expression result unused)}}}}
+  cit + 1;
 
   // expected-warning-re at +1 {{{{(ignoring return value of function declared with 'nodiscard' attribute|expression result unused)}}}}
   1 + it;
+  // expected-warning-re at +1 {{{{(ignoring return value of function declared with 'nodiscard' attribute|expression result unused)}}}}
+  1 + cit;
 
   // expected-warning-re at +1 {{{{(ignoring return value of function declared with 'nodiscard' attribute|expression result unused)}}}}
   it - 1;
+  // expected-warning-re at +1 {{{{(ignoring return value of function declared with 'nodiscard' attribute|expression result unused)}}}}
+  cit - 1;
 
   // expected-warning-re at +1 {{{{(ignoring return value of function declared with 'nodiscard' attribute|expression result unused)}}}}
   it - it;
+  // expected-warning-re at +1 {{{{(ignoring return value of function declared with 'nodiscard' attribute|expression result unused)}}}}
+  cit - cit;
 }


        


More information about the libcxx-commits mailing list