From c2697dbce0e6182524073dd8de0ec54701b35a09 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Sun, 13 Jul 2008 21:16:40 +0200 Subject: [PATCH] [svn r369] Fix nested classes when nestedVar is not generated. --- gen/classes.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gen/classes.cpp b/gen/classes.cpp index a5dde05a..f5daca9f 100644 --- a/gen/classes.cpp +++ b/gen/classes.cpp @@ -837,9 +837,14 @@ DValue* DtoNewClass(TypeClass* tc, NewExp* newexp) { Logger::println("Resolving nested context"); LOG_SCOPE; + // this value might be zero if it was not necessary to generate it ... LLValue* nest = gIR->func()->nestedVar; + // ... then revert to the this ptr if there is one if (!nest) nest = gIR->func()->thisVar; + // ... or just use zero, since it must be unused. + if (!nest) + nest = llvm::ConstantPointerNull::get(getVoidPtrType()); assert(nest); LLValue* gep = DtoGEPi(mem,0,2,"tmp"); nest = DtoBitCast(nest, gep->getType()->getContainedType(0));