summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2014-08-04 20:54:39 +0000
committerHans Wennborg <hans@hanshq.net>2014-08-04 20:54:39 +0000
commit7c4851e3ad57bc9d4856477dce95a1ec0692d677 (patch)
treeb3a53e3648d2982f277f01d1622b60688c3c6913 /clang/lib/Sema/SemaDecl.cpp
parent2120ecfe0843b79d2ec2020e7ee674cf931727a3 (diff)
downloadbcm5719-llvm-7c4851e3ad57bc9d4856477dce95a1ec0692d677.tar.gz
bcm5719-llvm-7c4851e3ad57bc9d4856477dce95a1ec0692d677.zip
Don't drop dllimport from qualified friend redeclarations (PR20512)
This matches MSVC's logic, which seems to be that when the friend declaration is qualified, it cannot be a declaration of a new symbol and so the dll linkage doesn't change. Differential Revision: http://reviews.llvm.org/D4764 llvm-svn: 214774
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 59953dc9e6c..5f65593aa83 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -5047,18 +5047,22 @@ static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl,
}
// A redeclaration is not allowed to drop a dllimport attribute, the only
- // exceptions being inline function definitions and local extern declarations.
+ // exceptions being inline function definitions, local extern declarations,
+ // and qualified friend declarations.
// NB: MSVC converts such a declaration to dllexport.
- bool IsInline = false, IsStaticDataMember = false;
+ bool IsInline = false, IsStaticDataMember = false, IsQualifiedFriend = false;
if (const auto *VD = dyn_cast<VarDecl>(NewDecl))
// Ignore static data because out-of-line definitions are diagnosed
// separately.
IsStaticDataMember = VD->isStaticDataMember();
- else if (const auto *FD = dyn_cast<FunctionDecl>(NewDecl))
+ else if (const auto *FD = dyn_cast<FunctionDecl>(NewDecl)) {
IsInline = FD->isInlined();
+ IsQualifiedFriend = FD->getQualifier() &&
+ FD->getFriendObjectKind() == Decl::FOK_Declared;
+ }
if (OldImportAttr && !HasNewAttr && !IsInline && !IsStaticDataMember &&
- !NewDecl->isLocalExternDecl()) {
+ !NewDecl->isLocalExternDecl() && !IsQualifiedFriend) {
S.Diag(NewDecl->getLocation(),
diag::warn_redeclaration_without_attribute_prev_attribute_ignored)
<< NewDecl << OldImportAttr;
OpenPOWER on IntegriCloud