mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-26 00:23:14 +01:00
Fixed D-style vararg arguments with types that have sizes bigger that pointers, yet are not aligned to pointer sizes. Fixes ticket #276 .
This commit is contained in:
@@ -141,8 +141,28 @@ void DtoBuildDVarArgList(std::vector<LLValue*>& args, std::vector<llvm::Attribut
|
||||
assert(argexp->type->ty != Ttuple);
|
||||
vtypes.push_back(DtoType(argexp->type));
|
||||
size_t sz = getTypePaddedSize(vtypes.back());
|
||||
if (sz < PTRSIZE)
|
||||
vtypes.back() = DtoSize_t();
|
||||
size_t asz = (sz + PTRSIZE - 1) & ~(PTRSIZE -1);
|
||||
if (sz != asz)
|
||||
{
|
||||
if (sz < PTRSIZE)
|
||||
{
|
||||
vtypes.back() = DtoSize_t();
|
||||
}
|
||||
else
|
||||
{
|
||||
// ok then... so we build some type that is big enough
|
||||
// and aligned to PTRSIZE
|
||||
std::vector<const LLType*> gah;
|
||||
gah.reserve(asz/PTRSIZE);
|
||||
size_t gah_sz = 0;
|
||||
while (gah_sz < asz)
|
||||
{
|
||||
gah.push_back(DtoSize_t());
|
||||
gah_sz += PTRSIZE;
|
||||
}
|
||||
vtypes.back() = LLStructType::get(gah, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
const LLStructType* vtype = LLStructType::get(vtypes);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user