File tree Expand file tree Collapse file tree 4 files changed +28
-1
lines changed Expand file tree Collapse file tree 4 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -487,6 +487,8 @@ Bug Fixes to C++ Support
487487- Clang now uses the correct set of template argument lists when comparing the constraints of
488488 out-of-line definitions and member templates explicitly specialized for a given implicit instantiation of
489489 a class template. (#GH102320)
490+ - Fixed a bug in lambda captures where ``constexpr `` class-type objects were not properly considered ODR-used in
491+ certain situations. (#GH47400), (#GH90896)
490492
491493Bug Fixes to AST Handling
492494^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change @@ -18843,7 +18843,16 @@ bool Sema::tryCaptureVariable(
1884318843 // We need to sync up the Declaration Context with the
1884418844 // FunctionScopeIndexToStopAt
1884518845 if (FunctionScopeIndexToStopAt) {
18846+ assert(!FunctionScopes.empty() && "No function scopes to stop at?");
1884618847 unsigned FSIndex = FunctionScopes.size() - 1;
18848+ // When we're parsing the lambda parameter list, the current DeclContext is
18849+ // NOT the lambda but its parent. So move away the current LSI before
18850+ // aligning DC and FunctionScopeIndexToStopAt.
18851+ if (auto *LSI = dyn_cast<LambdaScopeInfo>(FunctionScopes[FSIndex]);
18852+ LSI && !LSI->AfterParameterList)
18853+ --FSIndex;
18854+ assert(MaxFunctionScopesIndex <= FSIndex &&
18855+ "FSIndex is larger than the size of function scopes?");
1884718856 while (FSIndex != MaxFunctionScopesIndex) {
1884818857 DC = getLambdaAwareParentOfDeclContext(DC);
1884918858 --FSIndex;
Original file line number Diff line number Diff line change @@ -8679,7 +8679,7 @@ static void CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures(
86798679 while (isa_and_nonnull<CapturedDecl>(DC))
86808680 DC = DC->getParent ();
86818681 assert (
8682- CurrentLSI->CallOperator == DC &&
8682+ ( CurrentLSI->CallOperator == DC || !CurrentLSI-> AfterParameterList ) &&
86838683 " The current call operator must be synchronized with Sema's CurContext" );
86848684#endif // NDEBUG
86858685
Original file line number Diff line number Diff line change @@ -297,3 +297,19 @@ void __trans_tmp_1() {
297297}
298298
299299}
300+
301+ namespace GH47400 {
302+
303+ struct Foo {};
304+
305+ template <int , Foo f> struct Arr {};
306+
307+ constexpr bool foo () {
308+ constexpr Foo fff;
309+ [&]<int is>() {
310+ [&](Arr<is, fff>) {}({});
311+ }.template operator ()<42 >();
312+ return true ;
313+ }
314+
315+ } // namespace GH47400
You can’t perform that action at this time.
0 commit comments