From ceeff577001a59975bd9dc2e6887fccb719bbc7e Mon Sep 17 00:00:00 2001 From: Alexey Prokhin Date: Tue, 4 Jan 2011 20:03:33 +0300 Subject: [PATCH] Fixed CastExp::checkEscape() --- dmd2/expression.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dmd2/expression.c b/dmd2/expression.c index b7962efd..05f425b7 100644 --- a/dmd2/expression.c +++ b/dmd2/expression.c @@ -8014,6 +8014,21 @@ int CastExp::checkSideEffect(int flag) void CastExp::checkEscape() { Type *tb = type->toBasetype(); + +#if IN_LLVM + if (e1->op == TOKvar && + tb->ty == Tpointer && + e1->type->toBasetype()->ty == Tsarray) + { + VarDeclaration *v = ((VarExp*)e1)->var->isVarDeclaration(); + if (v) + { + if (!v->isDataseg() && !(v->storage_class & (STCref | STCout))) + error("escaping reference to local variable %s", v->toChars()); + } + } +#endif + if (tb->ty == Tarray && e1->op == TOKvar && e1->type->toBasetype()->ty == Tsarray) { VarExp *ve = (VarExp *)e1;