From 21659b6a5d6445c3f8d9f20b58a672c829665eaa Mon Sep 17 00:00:00 2001 From: Alexey Prokhin Date: Tue, 4 Jan 2011 19:06:25 +0300 Subject: [PATCH] Check in DtoNestedVariable() whether the needed frame can be accessed --- gen/nested.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gen/nested.cpp b/gen/nested.cpp index a55c1dba..973187ae 100644 --- a/gen/nested.cpp +++ b/gen/nested.cpp @@ -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)