Fix DMD Issue 3991 - Void initializers in unions considered overlapping

This commit is contained in:
Alexey Prokhin 2014-06-27 19:19:01 +04:00
parent 7597808a2d
commit f6126e7abf

View file

@ -87,6 +87,8 @@ llvm::Constant * IrAggr::getDefaultInit()
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
static bool isAligned(llvm::Type* type, size_t offset) { static bool isAligned(llvm::Type* type, size_t offset) {
if (offset == 0)
return true;
return gDataLayout->getABITypeAlignment(type) % offset == 0; return gDataLayout->getABITypeAlignment(type) % offset == 0;
} }
@ -278,6 +280,8 @@ void IrAggr::addFieldInitializers(
if (data[i].first) continue; if (data[i].first) continue;
VarDeclaration* vd = decl->fields[i]; VarDeclaration* vd = decl->fields[i];
if (vd->init && vd->init->isVoidInitializer())
continue;
unsigned vd_begin = vd->offset; unsigned vd_begin = vd->offset;
unsigned vd_end = vd_begin + vd->type->size(); unsigned vd_end = vd_begin + vd->type->size();