diff options
author | Hans Wennborg <hans@hanshq.net> | 2018-02-26 15:03:59 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2018-02-26 15:03:59 +0000 |
commit | 5695e505e8b731808a7f01fdd5df1127e24d19e8 (patch) | |
tree | 10d26cfce42d5fbc56f6abc1b4ce2d85416836e3 /lib/Sema | |
parent | e7e3e72f952508ffb4aa06572e2001317f305473 (diff) | |
download | clang-5695e505e8b731808a7f01fdd5df1127e24d19e8.tar.gz |
Re-commit r324991 "Fix for PR32992. Static const classes not exported."
Fix for PR32992. Static const classes not exported.
Patch by zahiraam!
(This re-lands the commit, but using S.MarkVariableReferenced instead of
S.PendingInstantiations.push_back, and with an additional test.)
Differential Revision: https://reviews.llvm.org/D42968
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326089 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 45adbe3a16..76ef9af73f 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -5476,7 +5476,7 @@ static void CheckAbstractClassUsage(AbstractUsageInfo &Info, } } -static void ReferenceDllExportedMethods(Sema &S, CXXRecordDecl *Class) { +static void ReferenceDllExportedMembers(Sema &S, CXXRecordDecl *Class) { Attr *ClassAttr = getDLLAttr(Class); if (!ClassAttr) return; @@ -5491,6 +5491,14 @@ static void ReferenceDllExportedMethods(Sema &S, CXXRecordDecl *Class) { return; for (Decl *Member : Class->decls()) { + // Defined static variables that are members of an exported base + // class must be marked export too. + auto *VD = dyn_cast<VarDecl>(Member); + if (VD && Member->getAttr<DLLExportAttr>() && + VD->getStorageClass() == SC_Static && + TSK == TSK_ImplicitInstantiation) + S.MarkVariableReferenced(VD->getLocation(), VD); + auto *MD = dyn_cast<CXXMethodDecl>(Member); if (!MD) continue; @@ -10902,12 +10910,12 @@ void Sema::ActOnFinishCXXNonNestedClass(Decl *D) { void Sema::referenceDLLExportedClassMethods() { if (!DelayedDllExportClasses.empty()) { - // Calling ReferenceDllExportedMethods might cause the current function to + // Calling ReferenceDllExportedMembers might cause the current function to // be called again, so use a local copy of DelayedDllExportClasses. SmallVector<CXXRecordDecl *, 4> WorkList; std::swap(DelayedDllExportClasses, WorkList); for (CXXRecordDecl *Class : WorkList) - ReferenceDllExportedMethods(*this, Class); + ReferenceDllExportedMembers(*this, Class); } } |