From ab94a6d60ca21ba710d21c13995be40cecc9a4c2 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 8 Nov 2012 23:53:50 +0100 Subject: [PATCH] Don't treat __ensure specially in LDC. The only change here is commenting out the Id::ensure check, the rest is just alignment of the code to upstream DMD. --- dmd/declaration.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/dmd/declaration.c b/dmd/declaration.c index c22096c8..2ecad32c 100644 --- a/dmd/declaration.c +++ b/dmd/declaration.c @@ -1533,25 +1533,33 @@ void VarDeclaration::checkNestedReference(Scope *sc, Loc loc) // The current function FuncDeclaration *fdthis = sc->parent->isFuncDeclaration(); - if (fdv && fdthis && fdv != fdthis && fdthis->ident != Id::ensure) + if (fdv && fdthis && fdv != fdthis) { - /* __ensure is always called directly, - * so it never becomes closure. - */ - - if (loc.filename) - fdthis->getLevel(loc, fdv); nestedref = 1; - fdv->nestedFrameRef = 1; +#if !IN_LLVM + // In LDC (D1), __ensure is actually just treated like a normal + // nested function, we don't use the magic stack layout hack like + // DMD (see DMD Bugzilla 7932 for why this was added). + if (fdthis->ident != Id::ensure) +#endif + { + /* __ensure is always called directly, + * so it never becomes closure. + */ + + if (loc.filename) + fdthis->getLevel(loc, fdv); + fdv->nestedFrameRef = 1; #if IN_LLVM #if DMDV1 - fdv->nestedVars.insert(this); + fdv->nestedVars.insert(this); #endif #endif - //printf("var %s in function %s is nested ref\n", toChars(), fdv->toChars()); - // __dollar creates problems because it isn't a real variable Bugzilla 3326 - if (ident == Id::dollar) - ::error(loc, "cannnot use $ inside a function literal"); + //printf("var %s in function %s is nested ref\n", toChars(), fdv->toChars()); + // __dollar creates problems because it isn't a real variable Bugzilla 3326 + if (ident == Id::dollar) + ::error(loc, "cannnot use $ inside a function literal"); + } } } }