[libcxx-commits] [libcxx] [libc++][array] Test `[[nodicard]]` with `array::const_iterator` (PR #202070)
Hristo Hristov via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Jun 6 11:50:31 PDT 2026
https://github.com/H-G-Hristov created https://github.com/llvm/llvm-project/pull/202070
Added tests with `array::const_iterator` for completeness.
Towards #172124
>From 23fb2d76cc72fa229a7a12de5e9cc6b0dce63af4 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sat, 6 Jun 2026 21:49:52 +0300
Subject: [PATCH] [libc++][array] Test `[[nodicard]]` with
`array::const_iterator`
Added tests with `array::const_iterator` for completeness.
---
.../sequences/array/nodiscard.iterator.verify.cpp | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
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