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
487
487
- Clang now uses the correct set of template argument lists when comparing the constraints of
488
488
out-of-line definitions and member templates explicitly specialized for a given implicit instantiation of
489
489
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)
490
492
491
493
Bug Fixes to AST Handling
492
494
^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change @@ -18843,7 +18843,16 @@ bool Sema::tryCaptureVariable(
18843
18843
// We need to sync up the Declaration Context with the
18844
18844
// FunctionScopeIndexToStopAt
18845
18845
if (FunctionScopeIndexToStopAt) {
18846
+ assert(!FunctionScopes.empty() && "No function scopes to stop at?");
18846
18847
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 off 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?");
18847
18856
while (FSIndex != MaxFunctionScopesIndex) {
18848
18857
DC = getLambdaAwareParentOfDeclContext(DC);
18849
18858
--FSIndex;
Original file line number Diff line number Diff line change @@ -8679,7 +8679,7 @@ static void CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures(
8679
8679
while (isa_and_nonnull<CapturedDecl>(DC))
8680
8680
DC = DC->getParent ();
8681
8681
assert (
8682
- CurrentLSI->CallOperator == DC &&
8682
+ ( CurrentLSI->CallOperator == DC || !CurrentLSI-> AfterParameterList ) &&
8683
8683
" The current call operator must be synchronized with Sema's CurContext" );
8684
8684
#endif // NDEBUG
8685
8685
Original file line number Diff line number Diff line change @@ -297,3 +297,19 @@ void __trans_tmp_1() {
297
297
}
298
298
299
299
}
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