Fix regression #3234 (#3235)

This commit is contained in:
Martin Kinkelin 2019-11-20 20:45:03 +01:00 committed by GitHub
parent 6c76a695f3
commit 649d19e2ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View file

@ -1822,11 +1822,12 @@ FuncDeclaration *getParentFunc(Dsymbol *sym) {
return nullptr;
}
// Static/non-extern(D) functions and function (not delegate) literals don't
// allow access to a parent context, even if they are nested.
// Static functions, non-extern(D) non-member functions and function (not
// delegate) literals don't allow access to a parent context, even if they are
// nested.
if (FuncDeclaration *fd = sym->isFuncDeclaration()) {
bool certainlyNewRoot =
fd->isStatic() || fd->linkage != LINKd ||
fd->isStatic() || (!fd->isThis() && fd->linkage != LINKd) ||
(fd->isFuncLiteralDeclaration() &&
static_cast<FuncLiteralDeclaration *>(fd)->tok == TOKfunction);
if (certainlyNewRoot) {

View file

@ -1,6 +1,6 @@
// RUN: %ldc -c %s
void foo()
void gh2808()
{
extern(C) void DoubleArrayToAnyArray(void* arg0)
{
@ -10,3 +10,14 @@ void foo()
auto arg = () { return local; }();
DoubleArrayToAnyArray(null);
}
void gh3234()
{
int i;
void nested() { ++i; }
extern (C++) class Visitor
{
void visit() { nested(); }
}
}