summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/RecordLayoutBuilder.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp
index 4466be6ca23..794ae6fdc59 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1286,9 +1286,15 @@ void RecordLayoutBuilder::LayoutFields(const RecordDecl *D) {
Context.getTypeInfo(FD->getType());
uint64_t TypeSize = FieldInfo.first;
unsigned FieldAlign = FieldInfo.second;
+ // This check is needed for 'long long' in -m32 mode.
+ if (TypeSize > FieldAlign)
+ FieldAlign = TypeSize;
FieldInfo = Context.getTypeInfo(LastFD->getType());
uint64_t TypeSizeLastFD = FieldInfo.first;
unsigned FieldAlignLastFD = FieldInfo.second;
+ // This check is needed for 'long long' in -m32 mode.
+ if (TypeSizeLastFD > FieldAlignLastFD)
+ FieldAlignLastFD = TypeSizeLastFD;
if (TypeSizeLastFD != TypeSize) {
uint64_t UnpaddedFieldOffset =
getDataSizeInBits() - UnfilledBitsInLastByte;
@@ -1382,6 +1388,10 @@ void RecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
uint64_t TypeSize = FieldInfo.first;
unsigned FieldAlign = FieldInfo.second;
+ // This check is needed for 'long long' in -m32 mode.
+ if (IsMsStruct && (TypeSize > FieldAlign))
+ FieldAlign = TypeSize;
+
if (ZeroLengthBitfield) {
// If a zero-length bitfield is inserted after a bitfield,
// and the alignment of the zero-length bitfield is
OpenPOWER on IntegriCloud