[PATCH] D99134: Lambdas are not necessarily locals. This resolves DR48250.
David Stone via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 17 10:18:24 PST 2022
davidstone updated this revision to Diff 409710.
davidstone added a comment.
Add unit test requested by Richard Smith
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,13 @@
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); }
+
+template <typename T> int e1 = [](auto){ return T(); }.operator()(T());
+int e2 = e1<int>;
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===================================================================
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -6034,7 +6034,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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99134.409710.patch
Type: text/x-patch
Size: 1433 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220217/8f05a7e2/attachment-0001.bin>
More information about the cfe-commits
mailing list