mirror of
https://github.com/intel/llvm.git
synced 2026-02-04 20:00:11 +08:00
Only the first zero-length bitfield decides alignment of
the followup data member in an ms_struct struct. // rdar:// 8823265 llvm-svn: 130795
This commit is contained in:
@@ -546,7 +546,8 @@ bool ASTContext::ZeroBitfieldFollowsNonBitfield(const FieldDecl *FD,
|
||||
bool ASTContext::ZeroBitfieldFollowsBitfield(const FieldDecl *FD,
|
||||
const FieldDecl *LastFD) const {
|
||||
return (FD->isBitField() && LastFD && LastFD->isBitField() &&
|
||||
FD->getBitWidth()-> EvaluateAsInt(*this).getZExtValue() == 0);
|
||||
FD->getBitWidth()-> EvaluateAsInt(*this).getZExtValue() == 0 &&
|
||||
LastFD->getBitWidth()-> EvaluateAsInt(*this).getZExtValue() != 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1359,9 +1359,11 @@ void RecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
|
||||
std::pair<uint64_t, unsigned> FieldInfo =
|
||||
Context.getTypeInfo(ZeroLengthBitfield->getType());
|
||||
unsigned ZeroLengthBitfieldAlignment = FieldInfo.second;
|
||||
if (ZeroLengthBitfieldAlignment > FieldAlign)
|
||||
// Ignore alignment of subsequent zero-length bitfields.
|
||||
if ((ZeroLengthBitfieldAlignment > FieldAlign) || (FieldSize == 0))
|
||||
FieldAlign = ZeroLengthBitfieldAlignment;
|
||||
ZeroLengthBitfield = 0;
|
||||
if (FieldSize)
|
||||
ZeroLengthBitfield = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,3 +43,49 @@ struct
|
||||
} ATTR t5;
|
||||
static int a5[(sizeof(t5) == 4) -1];
|
||||
|
||||
struct
|
||||
{
|
||||
char foo : 4;
|
||||
short : 0;
|
||||
long :0;
|
||||
char bar;
|
||||
} ATTR t6;
|
||||
static int a6[(sizeof(t6) == 4) -1];
|
||||
|
||||
struct
|
||||
{
|
||||
char foo : 4;
|
||||
long :0;
|
||||
short : 0;
|
||||
char bar;
|
||||
} ATTR t7;
|
||||
static int a7[(sizeof(t7) == 16) -1];
|
||||
|
||||
struct
|
||||
{
|
||||
char foo : 4;
|
||||
short : 0;
|
||||
long :0;
|
||||
char bar:7;
|
||||
} ATTR t8;
|
||||
static int a8[(sizeof(t8) == 4) -1];
|
||||
|
||||
struct
|
||||
{
|
||||
char foo : 4;
|
||||
long :0;
|
||||
short : 0;
|
||||
char bar: 8;
|
||||
} ATTR t9;
|
||||
static int a9[(sizeof(t9) == 16) -1];
|
||||
|
||||
struct
|
||||
{
|
||||
char foo : 4;
|
||||
char : 0;
|
||||
short : 0;
|
||||
int : 0;
|
||||
long :0;
|
||||
char bar;
|
||||
} ATTR t10;
|
||||
static int a10[(sizeof(t10) == 2) -1];
|
||||
|
||||
Reference in New Issue
Block a user