davidstone updated this revision to Diff 385508. davidstone added a comment.
Take into account Richard's comments Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D99134/new/ https://reviews.llvm.org/D99134 Files: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp clang/test/SemaCXX/lambdas-implicit-explicit-template.cpp Index: clang/test/SemaCXX/lambdas-implicit-explicit-template.cpp =================================================================== --- clang/test/SemaCXX/lambdas-implicit-explicit-template.cpp +++ clang/test/SemaCXX/lambdas-implicit-explicit-template.cpp @@ -39,3 +39,10 @@ const auto lambda = [&](auto arg1) {}; [&](auto arg2) { lambda.operator()(arg2); }(0); } + +auto d = [](auto) {}; + +template <typename T> +void d1(T x) { d.operator()(x); } + +void d2() { d1(0); } Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp =================================================================== --- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -6001,7 +6001,9 @@ (ParentDependsOnArgs && (ParentDC->isFunctionOrMethod() || isa<OMPDeclareReductionDecl>(ParentDC) || isa<OMPDeclareMapperDecl>(ParentDC))) || - (isa<CXXRecordDecl>(D) && cast<CXXRecordDecl>(D)->isLambda())) { + (isa<CXXRecordDecl>(D) && cast<CXXRecordDecl>(D)->isLambda() && + cast<CXXRecordDecl>(D)->getTemplateDepth() > + TemplateArgs.getNumRetainedOuterLevels())) { // D is a local of some kind. Look into the map of local // declarations to their instantiations. if (CurrentInstantiationScope) {
Index: clang/test/SemaCXX/lambdas-implicit-explicit-template.cpp =================================================================== --- clang/test/SemaCXX/lambdas-implicit-explicit-template.cpp +++ clang/test/SemaCXX/lambdas-implicit-explicit-template.cpp @@ -39,3 +39,10 @@ const auto lambda = [&](auto arg1) {}; [&](auto arg2) { lambda.operator()(arg2); }(0); } + +auto d = [](auto) {}; + +template <typename T> +void d1(T x) { d.operator()(x); } + +void d2() { d1(0); } Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp =================================================================== --- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -6001,7 +6001,9 @@ (ParentDependsOnArgs && (ParentDC->isFunctionOrMethod() || isa<OMPDeclareReductionDecl>(ParentDC) || isa<OMPDeclareMapperDecl>(ParentDC))) || - (isa<CXXRecordDecl>(D) && cast<CXXRecordDecl>(D)->isLambda())) { + (isa<CXXRecordDecl>(D) && cast<CXXRecordDecl>(D)->isLambda() && + cast<CXXRecordDecl>(D)->getTemplateDepth() > + TemplateArgs.getNumRetainedOuterLevels())) { // D is a local of some kind. Look into the map of local // declarations to their instantiations. if (CurrentInstantiationScope) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits