[libcxx-commits] [libcxx] [libc++][ranges] Add sentinel `OtherConst` cases for `[[nodiscard]]` tests in `enumerate_view` (PR #209289)

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jul 17 09:53:39 PDT 2026


================
@@ -53,7 +64,10 @@ void test() {
   std::as_const(it)[2];
 
   // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
-  it + 1;
+// expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
+it + 1;
+// expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
+1 + it;
----------------
Zingam wrote:

```suggestion
  // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
  it + 1;
  // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
  1 + it;
```

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


More information about the libcxx-commits mailing list