From 9c0514a9b1a0777bad4628f1ff1de670c1a85333 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Fri, 14 Jun 2013 15:49:15 +0200 Subject: [PATCH] Correctly load context for nested class members with own nested context. Fixes DMD testcase 'xtest46'. --- gen/nested.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gen/nested.cpp b/gen/nested.cpp index 3170eafc..2b7e7785 100644 --- a/gen/nested.cpp +++ b/gen/nested.cpp @@ -96,18 +96,21 @@ DValue* DtoNestedVariable(Loc loc, Type* astype, VarDeclaration* vd, bool byref) // get the nested context LLValue* ctx = 0; - if (irfunc->decl->isMember2()) - { + if (irfunc->nestedVar) { + // If this function has its own nested context struct, always load it. + ctx = irfunc->nestedVar; + dwarfValue = ctx; + } else if (irfunc->decl->isMember2()) { + // If this is a member function of a nested class without its own + // context, load the vthis member. AggregateDeclaration* cd = irfunc->decl->isMember2(); LLValue* val = irfunc->thisArg; if (cd->isClassDeclaration()) val = DtoLoad(val); ctx = DtoLoad(DtoGEPi(val, 0, cd->vthis->ir.irField->index, ".vthis")); - } - else if (irfunc->nestedVar) { - ctx = irfunc->nestedVar; - dwarfValue = ctx; } else { + // Otherwise, this is a simple nested function, load from the context + // argument. ctx = DtoLoad(irfunc->nestArg); dwarfValue = irfunc->nestArg; if (global.params.symdebug)