From cd516373b01f68282c644f32766edc3e376a312f Mon Sep 17 00:00:00 2001 From: Alexey Prokhin Date: Mon, 13 Feb 2012 16:30:39 +0400 Subject: [PATCH] Fixed interpreting of address expressions to ref foreach parameters --- dmd2/interpret.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/dmd2/interpret.c b/dmd2/interpret.c index 770b29a2..4056d686 100644 --- a/dmd2/interpret.c +++ b/dmd2/interpret.c @@ -1806,17 +1806,21 @@ Expression *AddrExp::interpret(InterState *istate, CtfeGoal goal) { VarExp *ve = (VarExp *)e1; if (ve->var->isFuncDeclaration()) return this; - if (type->ty != Tpointer) - { // Probably impossible - error("Cannot interpret %s at compile time", toChars()); - return EXP_CANT_INTERPRET; - } - Type *pointee = ((TypePointer *)type)->next; - if (isSafePointerCast(ve->var->type, pointee)) + if (!ve->var->isOut() && !ve->var->isRef() && + !ve->var->isImportedSymbol()) { - ve = new VarExp(loc, ve->var); - ve->type = type; - return ve; + if (type->ty != Tpointer) + { // Probably impossible + error("Cannot interpret %s at compile time", toChars()); + return EXP_CANT_INTERPRET; + } + Type *pointee = ((TypePointer *)type)->next; + if (isSafePointerCast(ve->var->type, pointee)) + { + ve = new VarExp(loc, ve->var); + ve->type = type; + return ve; + } } } else if (e1->op == TOKindex)