diff options
author | Devang Patel <dpatel@apple.com> | 2008-05-27 22:45:40 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2008-05-27 22:45:40 +0000 |
commit | 2fb86e61e3d8c39f7981d0270278541fb7cad255 (patch) | |
tree | a46a0e8bc45a1f8903755f0ed57e84b57bdc98d1 | |
parent | bf20b68e925f2b0e87eff0da49dae8a4dbc0fac7 (diff) |
Check first member alignment and uses packed struct if required.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51619 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CodeGenTypes.cpp | 2 | ||||
-rw-r--r-- | test/CodeGen/struct.c | 3 |
2 files changed, 5 insertions, 0 deletions
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index aa0d2ed053..5efde77a7d 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -516,6 +516,8 @@ void RecordOrganizer::layoutStructFields(const ASTRecordLayout &RL) { unsigned Align = CGT.getTargetData().getABITypeAlignment(Ty) * 8; if (llvmSize % Align) packedStruct = true; + else if (offset == 0 && RL.getAlignment() % Align) + packedStruct = true; llvmSize += size; CGT.addFieldInfo(FD, LLVMFields.size()); diff --git a/test/CodeGen/struct.c b/test/CodeGen/struct.c index 4c88c2539f..f17a7af76c 100644 --- a/test/CodeGen/struct.c +++ b/test/CodeGen/struct.c @@ -160,3 +160,6 @@ int f14(int i, ...) { a13 b = __builtin_va_arg(l, a13); return b.b; } + +/* Attribute packed */ +struct __attribute__((packed)) S2839 { double a[19]; signed char b; } s2839[5]; |