Allow definition of dllimport static fields in partial specializations (PR19956)
This expands the logic from r210141 to cover partial specializations too. llvm-svn: 210484
This commit is contained in:
parent
c817d6a5b5
commit
cd95922bd1
@ -9111,9 +9111,11 @@ Sema::FinalizeDeclaration(Decl *ThisDecl) {
|
||||
VD->isThisDeclarationADefinition()) {
|
||||
// We allow definitions of dllimport class template static data members
|
||||
// with a warning.
|
||||
CXXRecordDecl *Context =
|
||||
cast<CXXRecordDecl>(VD->getFirstDecl()->getDeclContext());
|
||||
bool IsClassTemplateMember =
|
||||
cast<CXXRecordDecl>(VD->getFirstDecl()->getDeclContext())
|
||||
->getDescribedClassTemplate();
|
||||
isa<ClassTemplatePartialSpecializationDecl>(Context) ||
|
||||
Context->getDescribedClassTemplate();
|
||||
|
||||
Diag(VD->getLocation(),
|
||||
IsClassTemplateMember
|
||||
|
||||
@ -581,12 +581,22 @@ namespace Vtordisp {
|
||||
}
|
||||
|
||||
namespace ClassTemplateStaticDef {
|
||||
// Regular template static field:
|
||||
template <typename T> struct __declspec(dllimport) S {
|
||||
static int x;
|
||||
};
|
||||
template <typename T> int S<T>::x;
|
||||
// CHECK-DAG: @"\01?x@?$S@H@ClassTemplateStaticDef@@2HA" = available_externally dllimport global i32 0
|
||||
// MSC-DAG: @"\01?x@?$S@H@ClassTemplateStaticDef@@2HA" = available_externally dllimport global i32 0
|
||||
int f() { return S<int>::x; }
|
||||
|
||||
// Partial class template specialization static field:
|
||||
template <typename A> struct T;
|
||||
template <typename A> struct __declspec(dllimport) T<A*> {
|
||||
static int x;
|
||||
};
|
||||
template <typename A> int T<A*>::x;
|
||||
// M32-DAG: @"\01?x@?$T@PAX@ClassTemplateStaticDef@@2HA" = available_externally dllimport global i32 0
|
||||
int g() { return T<void*>::x; }
|
||||
}
|
||||
|
||||
namespace PR19933 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user