Skip to content

Commit 997a9b6

Browse files
committed
Allow reflection of local entities that aren't init-captures.
1 parent 91836b9 commit 997a9b6

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3153,7 +3153,7 @@ def err_reflect_overload_set : Error<
31533153
def err_reflect_nttp : Error<
31543154
"cannot take the reflection of a non-type template parameter">;
31553155
def err_reflect_init_capture : Error<
3156-
"cannot take the reflection of a captured local entity">;
3156+
"cannot take the reflection of a local entity declared by init-capture">;
31573157
def err_template_arg_bad_reflection_kind : Error<
31583158
"reflection of this kind cannot appear as a template argument">;
31593159
def err_reflect_dependent_splice : Error<

clang/lib/Sema/SemaReflect.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,8 +816,7 @@ ExprResult Sema::ActOnCXXReflectExpr(SourceLocation OpLoc,
816816
return BuildCXXReflectExpr(OpLoc, NameInfo.getBeginLoc(), ND);
817817

818818
if (auto *VD = dyn_cast<VarDecl>(ND);
819-
VD && (VD->isInitCapture() ||
820-
NeedToCaptureVariable(VD, Id.StartLocation))) {
819+
VD && (VD->isInitCapture())) {
821820
Diag(Id.StartLocation, diag::err_reflect_init_capture)
822821
<< Id.getSourceRange();
823822
return ExprError();

clang/test/Reflection/lift-operator.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,19 @@ consteval int fn(decltype(^^::) x = ^^x) { return 0; }
166166
constexpr int x = fn();
167167
} // namspace self_reference
168168

169+
// ==============
170+
// lambda_capture
171+
// ==============
172+
173+
namespace lambda_capture {
174+
void fn() {
175+
int x;
176+
[=]<auto r> {
177+
static_assert(^^x == r);
178+
}.operator()<^^x>();
179+
}
180+
} // namespace lambda_capture
181+
169182
// =======================================
170183
// bb_clang_p2996_issue_35_regression_test
171184
// =======================================

0 commit comments

Comments
 (0)