diff options
| author | Alex Lorenz <arphaman@gmail.com> | 2018-01-31 21:59:02 +0000 |
|---|---|---|
| committer | Alex Lorenz <arphaman@gmail.com> | 2018-01-31 21:59:02 +0000 |
| commit | de07acb9a53066cb9c2a3e4bc4edd7be06db17d1 (patch) | |
| tree | 8757b8eb6c7648c12fe2234022062aba529f8c36 /clang/lib/AST | |
| parent | a75677c2b7d63475d235b684e4bd52955439892e (diff) | |
| download | bcm5719-llvm-de07acb9a53066cb9c2a3e4bc4edd7be06db17d1.tar.gz bcm5719-llvm-de07acb9a53066cb9c2a3e4bc4edd7be06db17d1.zip | |
[PR32482] Fix bitfield layout for -mms-bitfield and pragma pack
The patch ensures that a new storage unit is created when the new bitfield's
size is wider than the available bits.
rdar://36343145
Differential Revision: https://reviews.llvm.org/D42660
llvm-svn: 323921
Diffstat (limited to 'clang/lib/AST')
| -rw-r--r-- | clang/lib/AST/RecordLayoutBuilder.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index a9d43dfa80c..dddacf2a5fe 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/lib/AST/RecordLayoutBuilder.cpp @@ -1504,9 +1504,10 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) { FieldAlign = TypeSize; // If the previous field was not a bitfield, or was a bitfield - // with a different storage unit size, we're done with that - // storage unit. - if (LastBitfieldTypeSize != TypeSize) { + // with a different storage unit size, or if this field doesn't fit into + // the current storage unit, we're done with that storage unit. + if (LastBitfieldTypeSize != TypeSize || + UnfilledBitsInLastUnit < FieldSize) { // Also, ignore zero-length bitfields after non-bitfields. if (!LastBitfieldTypeSize && !FieldSize) FieldAlign = 1; |

