From 26e4f91cdca2d1339c0036bfeb3a29e14c5df769 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Fri, 16 Mar 2012 23:27:54 +0100 Subject: [PATCH] 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}; --- --- ir/irstruct.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ir/irstruct.cpp b/ir/irstruct.cpp index 5befa67c..5275d1f7 100644 --- a/ir/irstruct.cpp +++ b/ir/irstruct.cpp @@ -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