Check in DtoNestedVariable() whether the needed frame can be accessed

This commit is contained in:
Alexey Prokhin 2011-01-04 19:06:25 +03:00
parent 67daf2fe0a
commit 21659b6a5d

View file

@ -100,6 +100,17 @@ DValue* DtoNestedVariable(Loc loc, Type* astype, VarDeclaration* vd, bool byref)
assert(vdparent);
IrFunction* irfunc = gIR->func();
// Check whether we can access the needed frame
FuncDeclaration *fd = irfunc->decl;
while (fd != vdparent) {
if (fd->isStatic()) {
error(loc, "function %s cannot access frame of function %s", irfunc->decl->toPrettyChars(), vdparent->toPrettyChars());
return new DVarValue(astype, vd, llvm::UndefValue::get(getPtrToType(DtoType(astype))));
}
fd = getParentFunc(fd, false);
assert(fd);
}
// is the nested variable in this scope?
if (vdparent == irfunc->decl)