[clang] 5064c4c - [Clang][Sema] Bump the instantiated index when skipping past non-init-captures (#110887)

via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 2 17:24:23 PDT 2024


Author: Younan Zhang
Date: 2024-10-03T08:24:20+08:00
New Revision: 5064c4c4f8f5b09c51bab9b18f62a5c3012989c0

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

LOG: [Clang][Sema] Bump the instantiated index when skipping past non-init-captures (#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 so far.

Fixes #110721

Added: 
    

Modified: 
    clang/lib/Sema/SemaConcept.cpp
    clang/test/SemaTemplate/concepts-lambda.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 67fc603e9ce1d5..998a148a7d24a1 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


        


More information about the cfe-commits mailing list