forked from OSchip/llvm-project
Sema: Fix a subtle i64 -> i32 truncation which broke layout of large structures
with bit-fields. llvm-svn: 107185
This commit is contained in:
parent
a4575f5b31
commit
f35e76552f
|
@ -1296,7 +1296,7 @@ void RecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
|
|||
|
||||
// Check if we need to add padding to give the field the correct alignment.
|
||||
if (FieldSize == 0 || (FieldOffset & (FieldAlign-1)) + FieldSize > TypeSize)
|
||||
FieldOffset = (FieldOffset + (FieldAlign-1)) & ~(FieldAlign-1);
|
||||
FieldOffset = llvm::RoundUpToAlignment(FieldOffset, FieldAlign);
|
||||
|
||||
// Padding members don't affect overall alignment.
|
||||
if (!D->getIdentifier())
|
||||
|
|
|
@ -30,3 +30,13 @@ CHECK_ALIGN(struct, e, 1)
|
|||
struct f {__attribute((aligned(8))) int x : 30, y : 30, z : 30;};
|
||||
CHECK_SIZE(struct, f, 24)
|
||||
CHECK_ALIGN(struct, f, 8)
|
||||
|
||||
// Large structure (overflows i32, in bits).
|
||||
struct s0 {
|
||||
char a[0x32100000];
|
||||
int x:30, y:30;
|
||||
};
|
||||
|
||||
CHECK_SIZE(struct, s0, 0x32100008)
|
||||
CHECK_ALIGN(struct, s0, 4)
|
||||
|
||||
|
|
Loading…
Reference in New Issue