Respect struct packing when generating struct initializers.

Fixes issue #88.

Previously, invalid code would be generated in cases like the following:
---
align(1) struct Test {
    string str;
    int id;
}

Test test = {"asdf", 4};
---
This commit is contained in:
David Nadlinger
2012-03-16 23:27:54 +01:00
parent dee054fae0
commit 26e4f91cdc

View File

@@ -388,9 +388,9 @@ LLConstant * IrStruct::createStructInitializer(StructInitializer * si)
for (itr = constants.begin(); itr != end; ++itr)
types.push_back((*itr)->getType());
if (!ltype)
ltype = LLStructType::get(gIR->context(), types);
ltype = LLStructType::get(gIR->context(), types, packed);
else
ltype->setBody(types);
ltype->setBody(types, packed);
}
// build constant