File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -19719,7 +19719,9 @@ bool Sema::tryCaptureVariable(
19719
19719
// we can bailout early.
19720
19720
if (CapturingFunctionScopes == 0 && (!BuildAndDiagnose || VarDC == DC))
19721
19721
return true;
19722
-
19722
+ // Expression in `RequiresExprBodyDecl` should not be captured.
19723
+ if (isa<RequiresExprBodyDecl>(CurContext))
19724
+ return true;
19723
19725
const auto *VD = dyn_cast<VarDecl>(Var);
19724
19726
if (VD) {
19725
19727
if (VD->isInitCapture())
Original file line number Diff line number Diff line change
1
+ // RUN: %clang -fsyntax-only -std=c++20 -Xclang -verify %s
2
+
3
+ // expected-no-diagnostics
4
+
5
+ auto GH69307_Func_1 () {
6
+ constexpr auto b = 1 ;
7
+ return [&](auto c) -> int
8
+ requires requires { b + c; }
9
+ { return 1 ; };
10
+ };
11
+ auto GH69307_Func_Ret = GH69307_Func_1()(1 );
12
+
13
+ auto GH69307_Lambda_1 = []() {
14
+ return [&](auto c) -> int
15
+ requires requires { c; }
16
+ { return 1 ; };
17
+ };
18
+ auto GH69307_Lambda_1_Ret = GH69307_Lambda_1()(1 );
19
+
20
+ auto GH69307_Lambda_2 = [](auto c) {
21
+ return [&]() -> int
22
+ requires requires { c; }
23
+ { return 1 ; };
24
+ };
25
+ auto GH69307_Lambda_2_Ret = GH69307_Lambda_2(1 )();
You can’t perform that action at this time.
0 commit comments