[svn r29] * Fixed structs inside struct literals

This commit is contained in:
Tomas Lindquist Olsen
2007-10-04 10:22:56 +02:00
parent 24c3e2649a
commit 9fd43121db
2 changed files with 29 additions and 1 deletions

View File

@@ -1378,7 +1378,12 @@ elem* StructLiteralExp::toElem(IRState* p)
elem* ve = vx->toElem(p);
llvm::Value* val = ve->getValue();
Logger::cout() << *val << " | " << *arrptr << '\n';
new llvm::StoreInst(val, arrptr, p->scopebb());
if (vx->type->ty == Tstruct) {
TypeStruct* ts = (TypeStruct*)vx->type;
LLVM_DtoStructCopy(ts,arrptr,val);
}
else
new llvm::StoreInst(val, arrptr, p->scopebb());
delete ve;
}
else {

23
test/structs5.d Normal file
View File

@@ -0,0 +1,23 @@
module structs5;
void main()
{
{S s = S();}
{T t = T(1);}
{U u = U();}
}
struct S
{
}
struct T
{
int i;
}
struct U
{
S s;
long l;
}