MS ABI: Records with fields with required aligmnet shouldn't be common
llvm-svn: 227954
This commit is contained in:
parent
5821ff78ef
commit
e1a0b2e2af
|
@ -2162,9 +2162,25 @@ static bool isVarDeclStrongDefinition(const ASTContext &Context,
|
|||
|
||||
// Declarations with a required alignment do not have common linakge in MSVC
|
||||
// mode.
|
||||
if (Context.getLangOpts().MSVCCompat &&
|
||||
(Context.isAlignmentRequired(D->getType()) || D->hasAttr<AlignedAttr>()))
|
||||
return true;
|
||||
if (Context.getLangOpts().MSVCCompat) {
|
||||
if (D->hasAttr<AlignedAttr>())
|
||||
return true;
|
||||
QualType VarType = D->getType();
|
||||
if (Context.isAlignmentRequired(VarType))
|
||||
return true;
|
||||
|
||||
if (const auto *RT = VarType->getAs<RecordType>()) {
|
||||
const RecordDecl *RD = RT->getDecl();
|
||||
for (const FieldDecl *FD : RD->fields()) {
|
||||
if (FD->isBitField())
|
||||
continue;
|
||||
if (FD->hasAttr<AlignedAttr>())
|
||||
return true;
|
||||
if (Context.isAlignmentRequired(FD->getType()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -18,3 +18,8 @@ struct __declspec(align(64)) S {
|
|||
char fd;
|
||||
} s;
|
||||
// CHECK-DAG: @s = global %struct.S zeroinitializer, align 64
|
||||
|
||||
struct Wrap {
|
||||
struct S x;
|
||||
} w;
|
||||
// CHECK-DAG: @w = global %struct.Wrap zeroinitializer, align 64
|
||||
|
|
Loading…
Reference in New Issue