mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-01 12:33:13 +01:00
[svn r72] Calling a nested function that is not a delegate was not working.
This commit is contained in:
10
gen/toir.c
10
gen/toir.c
@@ -1036,6 +1036,7 @@ elem* CallExp::toElem(IRState* p)
|
||||
if (fn->arg || delegateCall) n++;
|
||||
if (retinptr) n++;
|
||||
if (tf->linkage == LINKd && tf->varargs == 1) n+=2;
|
||||
if (fn->funcdecl && fn->funcdecl->isNested()) n++;
|
||||
|
||||
llvm::Value* funcval = fn->getValue();
|
||||
assert(funcval != 0);
|
||||
@@ -1127,6 +1128,15 @@ elem* CallExp::toElem(IRState* p)
|
||||
++j;
|
||||
++argiter;
|
||||
}
|
||||
// nested call
|
||||
else if (fn->funcdecl && fn->funcdecl->isNested()) {
|
||||
Logger::println("Nested Call");
|
||||
llvm::Value* contextptr = p->func().decl->llvmNested;
|
||||
assert(contextptr);
|
||||
llargs[j] = p->ir->CreateBitCast(contextptr, llvm::PointerType::get(llvm::Type::Int8Ty), "tmp");
|
||||
++j;
|
||||
++argiter;
|
||||
}
|
||||
|
||||
// va arg function special argument passing
|
||||
if (va_magic) {
|
||||
|
||||
@@ -789,6 +789,7 @@ void FuncDeclaration::toObjFile()
|
||||
VarDeclaration* vd = *i;
|
||||
if (vd->isParameter()) {
|
||||
gIR->ir->CreateStore(vd->llvmValue, LLVM_DtoGEPi(llvmNested, 0, vd->llvmNestedIndex, "tmp"));
|
||||
vd->llvmValue = llvmNested;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
12
test/nested3.d
Normal file
12
test/nested3.d
Normal file
@@ -0,0 +1,12 @@
|
||||
module nested3;
|
||||
|
||||
void main()
|
||||
{
|
||||
int i;
|
||||
void test()
|
||||
{
|
||||
i = 3;
|
||||
}
|
||||
test();
|
||||
assert(i == 3);
|
||||
}
|
||||
Reference in New Issue
Block a user