Fix issue 726: Wrong alignment for struct fields on x86_64/amd64

This commit is contained in:
Alexey Prokhin 2014-10-11 16:09:25 +04:00
parent 0b180be099
commit 9314fc1c1c
8 changed files with 49 additions and 16 deletions

View file

@ -96,7 +96,14 @@ IrTypeClass* IrTypeClass::get(ClassDeclaration* cd)
LOG_SCOPE;
IF_LOG Logger::println("Instance size: %u", cd->structsize);
AggrTypeBuilder builder(false);
// This class may contain an align declaration. See issue 726.
t->packed = false;
for (ClassDeclaration *base = cd; base != 0 && !t->packed; base = base->baseClass)
{
t->packed = isPacked(base);
}
AggrTypeBuilder builder(t->packed);
// add vtbl
builder.addType(llvm::PointerType::get(t->vtbl_type, 0), Target::ptrsize);
@ -127,7 +134,7 @@ IrTypeClass* IrTypeClass::get(ClassDeclaration* cd)
fatal();
// set struct body and copy GEP indices
isaStruct(t->type)->setBody(builder.defaultTypes(), false);
isaStruct(t->type)->setBody(builder.defaultTypes(), t->packed);
t->varGEPIndices = builder.varGEPIndices();
// VTBL