[llvm] [clang] [clang-tools-extra] [clang] reject to capture variable in `RequiresExprBodyDecl` (PR #78598)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 5 07:44:34 PST 2024


================
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-lambda-capture -Wused-but-marked-unused -Wno-uninitialized -verify -std=c++20 %s
+
+void test() {
+  int i;
+  auto explicit_by_value_unused_requires = [i] (auto) requires requires { i; } {}; // expected-warning{{lambda capture 'i' is not required to be captured for this use}}
----------------
erichkeane wrote:

It would be PARTICULARLY good if we could 'remember' that it was 'used' in the requires clause so we can add a note that says something like (please consider wording and write better:)), `note: use in requires expr doesn't use captures because they are special`.

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


More information about the cfe-commits mailing list