Check whether next slot meets field type's alignment requirements.

If it does not then assert at the moment.

llvm-svn: 43576
This commit is contained in:
Devang Patel 2007-10-31 21:01:37 +00:00
parent aaba027717
commit 6029cbf872
1 changed files with 4 additions and 1 deletions

View File

@ -368,7 +368,10 @@ void RecordOrganizer::layoutStructFields(CodeGenTypes &CGT,
const llvm::Type *Ty = CGT.ConvertType(FD->getType());
uint64_t Offset = RL.getFieldOffset(FieldNo);
assert (Offset == Cursor && "FIXME Invalid struct layout");
unsigned align = CGT.getTargetData().getABITypeAlignment(Ty);
if (Cursor % align != 0)
assert (Offset == Cursor && "FIXME Invalid struct layout");
Cursor += CGT.getTargetData().getTypeSizeInBits(Ty);
Fields.push_back(Ty);