This revision was automatically updated to reflect the committed changes.
Closed by commit rG0bff3a965022: Lambdas are not necessarily locals. This
resolves DR48250. (authored by davidstone, committed by erichkeane).
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) {
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) {
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits