https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/110887
Otherwise, we would probably have an unmatched instantiated declaration for init-captures when they come after a non-init capture. No release note because the bug only affects the trunk. Fixes #110721 >From 0c36520e882767ea478c5bd94c367a8e1029cd93 Mon Sep 17 00:00:00 2001 From: Younan Zhang <zyn7...@gmail.com> Date: Thu, 3 Oct 2024 00:45:51 +0800 Subject: [PATCH] [Clang][Sema] Bump the instantiated index when skipping past non-init-captures Otherwise, we would probably have an unmatched instantiated declaration for init-captures when they come after a non-init capture. --- clang/lib/Sema/SemaConcept.cpp | 1 + clang/test/SemaTemplate/concepts-lambda.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp index 6a1b32598bb4a6..41ca372743d2a5 100644 --- a/clang/lib/Sema/SemaConcept.cpp +++ b/clang/lib/Sema/SemaConcept.cpp @@ -728,6 +728,7 @@ bool Sema::addInstantiatedCapturesToScope( ValueDecl *CapturedPattern = CapturePattern.getCapturedVar(); if (!CapturedPattern->isInitCapture()) { + Instantiated++; continue; } diff --git a/clang/test/SemaTemplate/concepts-lambda.cpp b/clang/test/SemaTemplate/concepts-lambda.cpp index 9c5807bbabdcbf..829a71bc703feb 100644 --- a/clang/test/SemaTemplate/concepts-lambda.cpp +++ b/clang/test/SemaTemplate/concepts-lambda.cpp @@ -279,3 +279,18 @@ void dependent_capture_packs() { L(V<0>{}, V<1>{}, V<2>{})(V<3>{}, V<4>{})(1); } } // namespace init_captures + +namespace GH110721 { + +template <int N> void connect() { + int x = N, y = N; + [x, y = y]() + requires requires { x; } + {}(); +} + +void foo() { + connect<42>(); +} + +} // namespace GH110721 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits