diff options
-rw-r--r-- | lib/AST/RecordLayoutBuilder.cpp | 17 | ||||
-rw-r--r-- | test/Sema/pragma-ms_struct.c | 21 |
2 files changed, 35 insertions, 3 deletions
diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp index c92116ac6c..3e413befd8 100644 --- a/lib/AST/RecordLayoutBuilder.cpp +++ b/lib/AST/RecordLayoutBuilder.cpp @@ -1483,13 +1483,21 @@ void RecordLayoutBuilder::LayoutFields(const RecordDecl *D) { uint64_t TypeSize = FieldInfo.first; unsigned FieldAlign = FieldInfo.second; // This check is needed for 'long long' in -m32 mode. - if (TypeSize > FieldAlign) + if (TypeSize > FieldAlign && + (Context.hasSameType(FD->getType(), + Context.UnsignedLongLongTy) + ||Context.hasSameType(FD->getType(), + Context.LongLongTy))) 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) + if (TypeSizeLastFD > FieldAlignLastFD && + (Context.hasSameType(LastFD->getType(), + Context.UnsignedLongLongTy) + || Context.hasSameType(LastFD->getType(), + Context.LongLongTy))) FieldAlignLastFD = TypeSizeLastFD; if (TypeSizeLastFD != TypeSize) { @@ -1640,7 +1648,10 @@ void RecordLayoutBuilder::LayoutBitField(const FieldDecl *D) { unsigned FieldAlign = FieldInfo.second; // This check is needed for 'long long' in -m32 mode. - if (IsMsStruct && (TypeSize > FieldAlign)) + if (IsMsStruct && (TypeSize > FieldAlign) && + (Context.hasSameType(D->getType(), + Context.UnsignedLongLongTy) + || Context.hasSameType(D->getType(), Context.LongLongTy))) FieldAlign = TypeSize; if (ZeroLengthBitfield) { diff --git a/test/Sema/pragma-ms_struct.c b/test/Sema/pragma-ms_struct.c index b2c2684c61..d76ee8bab3 100644 --- a/test/Sema/pragma-ms_struct.c +++ b/test/Sema/pragma-ms_struct.c @@ -32,3 +32,24 @@ struct S { } __attribute__((ms_struct)) t2; +// rdar://10513599 +#pragma ms_struct on + +typedef struct +{ +void *pv; +int l; +} Foo; + +typedef struct +{ +void *pv1; +Foo foo; +unsigned short fInited : 1; +void *pv2; +} PackOddity; + +#pragma ms_struct off + +static int arr[sizeof(PackOddity) == 40 ? 1 : -1]; + |