summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2018-01-31 21:59:02 +0000
committerAlex Lorenz <arphaman@gmail.com>2018-01-31 21:59:02 +0000
commitde07acb9a53066cb9c2a3e4bc4edd7be06db17d1 (patch)
tree8757b8eb6c7648c12fe2234022062aba529f8c36 /clang/lib/AST
parenta75677c2b7d63475d235b684e4bd52955439892e (diff)
downloadbcm5719-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.cpp7
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;
OpenPOWER on IntegriCloud