Skip to content

Commit 5064c4c

Browse files
authored
[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
1 parent 7fe43ad commit 5064c4c

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

clang/lib/Sema/SemaConcept.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,7 @@ bool Sema::addInstantiatedCapturesToScope(
728728
ValueDecl *CapturedPattern = CapturePattern.getCapturedVar();
729729

730730
if (!CapturedPattern->isInitCapture()) {
731+
Instantiated++;
731732
continue;
732733
}
733734

clang/test/SemaTemplate/concepts-lambda.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,3 +279,18 @@ void dependent_capture_packs() {
279279
L(V<0>{}, V<1>{}, V<2>{})(V<3>{}, V<4>{})(1);
280280
}
281281
} // namespace init_captures
282+
283+
namespace GH110721 {
284+
285+
template <int N> void connect() {
286+
int x = N, y = N;
287+
[x, y = y]()
288+
requires requires { x; }
289+
{}();
290+
}
291+
292+
void foo() {
293+
connect<42>();
294+
}
295+
296+
} // namespace GH110721

0 commit comments

Comments
 (0)