forked from OSchip/llvm-project
Lambdas are not necessarily locals. This resolves DR48250.
Differential Revision: https://reviews.llvm.org/D99134
This commit is contained in:
parent
6527b2a4d5
commit
0bff3a9650
|
@ -6034,7 +6034,9 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
|
||||||
(ParentDependsOnArgs && (ParentDC->isFunctionOrMethod() ||
|
(ParentDependsOnArgs && (ParentDC->isFunctionOrMethod() ||
|
||||||
isa<OMPDeclareReductionDecl>(ParentDC) ||
|
isa<OMPDeclareReductionDecl>(ParentDC) ||
|
||||||
isa<OMPDeclareMapperDecl>(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
|
// D is a local of some kind. Look into the map of local
|
||||||
// declarations to their instantiations.
|
// declarations to their instantiations.
|
||||||
if (CurrentInstantiationScope) {
|
if (CurrentInstantiationScope) {
|
||||||
|
|
|
@ -39,3 +39,13 @@ void c2() {
|
||||||
const auto lambda = [&](auto arg1) {};
|
const auto lambda = [&](auto arg1) {};
|
||||||
[&](auto arg2) { lambda.operator()(arg2); }(0);
|
[&](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>;
|
||||||
|
|
Loading…
Reference in New Issue