diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-02-03 08:49:32 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-02-03 08:49:32 +0000 |
commit | a1311366decdac3a9d9405a4d6fdf697cef08a10 (patch) | |
tree | f5f5065892cf45c386fff28b5b93a072f2eed4f9 /lib/CodeGen/CodeGenModule.cpp | |
parent | 34bc82537783f693413a0346e55ec16a60c0497c (diff) | |
download | clang-a1311366decdac3a9d9405a4d6fdf697cef08a10.tar.gz |
MS ABI: Records with fields with required aligmnet shouldn't be common
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227954 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index dc7ec6f654..bc52028a06 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -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; } |