@@ -1614,7 +1614,19 @@ bool TemplateInstantiator::AlreadyTransformed(QualType T) {
1614
1614
if (T.isNull ())
1615
1615
return true ;
1616
1616
1617
- if (T->isInstantiationDependentType () || T->isVariablyModifiedType ())
1617
+ bool DependentLambdaType = false ;
1618
+ QualType DesugaredType = T.getDesugaredType (SemaRef.getASTContext ());
1619
+ CXXRecordDecl *RD = DesugaredType->getAsCXXRecordDecl ();
1620
+ if (RD && RD->isLambda ()) {
1621
+ QualType LambdaCallType = RD->getLambdaCallOperator ()->getType ();
1622
+ if (LambdaCallType->isInstantiationDependentType () ||
1623
+ LambdaCallType->isVariablyModifiedType ()) {
1624
+ DependentLambdaType = true ;
1625
+ }
1626
+ }
1627
+
1628
+ if (T->isInstantiationDependentType () || T->isVariablyModifiedType () ||
1629
+ DependentLambdaType)
1618
1630
return false ;
1619
1631
1620
1632
getSema ().MarkDeclarationsReferencedInType (Loc, T);
@@ -2683,9 +2695,21 @@ QualType Sema::SubstType(QualType T,
2683
2695
" Cannot perform an instantiation without some context on the "
2684
2696
" instantiation stack" );
2685
2697
2698
+ bool DependentLambdaType = false ;
2699
+ QualType DesugaredType = T.getDesugaredType (getASTContext ());
2700
+ CXXRecordDecl *RD = DesugaredType->getAsCXXRecordDecl ();
2701
+ if (RD && RD->isLambda ()) {
2702
+ QualType LambdaCallType = RD->getLambdaCallOperator ()->getType ();
2703
+ if (LambdaCallType->isInstantiationDependentType () ||
2704
+ LambdaCallType->isVariablyModifiedType ()) {
2705
+ DependentLambdaType = true ;
2706
+ }
2707
+ }
2708
+
2686
2709
// If T is not a dependent type or a variably-modified type, there
2687
2710
// is nothing to do.
2688
- if (!T->isInstantiationDependentType () && !T->isVariablyModifiedType ())
2711
+ if (!T->isInstantiationDependentType () && !T->isVariablyModifiedType () &&
2712
+ !DependentLambdaType)
2689
2713
return T;
2690
2714
2691
2715
TemplateInstantiator Instantiator (*this , TemplateArgs, Loc, Entity);
0 commit comments