aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-10-02 04:52:12 +0000
committerAnders Carlsson <andersca@mac.com>2009-10-02 04:52:12 +0000
commit2df96e7019853d80ea599453925bd324cd110a8f (patch)
tree85434a5a65206e011863c1d6b697ac62429b2bb2 /lib/CodeGen
parent3d363c596d295b38cae765eae510fbc2e7c80e1a (diff)
Don't update the struct alignment when adding fields to a packed struct. Fixes PR5118.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83235 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/CGExprConstant.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp
index fae0e369a9..c67b41f4e2 100644
--- a/lib/CodeGen/CGExprConstant.cpp
+++ b/lib/CodeGen/CGExprConstant.cpp
@@ -85,7 +85,12 @@ class VISIBILITY_HIDDEN ConstStructBuilder {
// Add the field.
Elements.push_back(C);
NextFieldOffsetInBytes = AlignedNextFieldOffsetInBytes + getSizeInBytes(C);
- LLVMStructAlignment = std::max(LLVMStructAlignment, FieldAlignment);
+
+ if (Packed)
+ assert(LLVMStructAlignment == 1 && "Packed struct not byte-aligned!");
+ else
+ LLVMStructAlignment = std::max(LLVMStructAlignment, FieldAlignment);
+
return true;
}