diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 9a6434579f4d..3438b5f89fff 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -7687,7 +7687,6 @@ Sema::ActOnExplicitInstantiation(Scope *S, assert(DelayedDllExportClasses.empty() && "delayed exports present at explicit instantiation"); checkClassLevelDLLAttribute(Def); - referenceDLLExportedClassMethods(); // Propagate attribute to base class templates. for (auto &B : Def->bases()) { @@ -7695,6 +7694,8 @@ Sema::ActOnExplicitInstantiation(Scope *S, B.getType()->getAsCXXRecordDecl())) propagateDLLAttrToBaseClassTemplate(Def, A, BT, B.getLocStart()); } + + referenceDLLExportedClassMethods(); } } diff --git a/clang/test/CodeGenCXX/windows-implicit-dllexport-template-specialization.cpp b/clang/test/CodeGenCXX/windows-implicit-dllexport-template-specialization.cpp new file mode 100644 index 000000000000..c2f2a0773e90 --- /dev/null +++ b/clang/test/CodeGenCXX/windows-implicit-dllexport-template-specialization.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -std=c++11 -triple i686-windows -fdeclspec -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MS +// RUN: %clang_cc1 -std=c++11 -triple i686-windows-itanium -fdeclspec -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-IA + +template +struct s {}; + +template +class t : s {}; + +extern template class t; +template class __declspec(dllexport) t; + +// CHECK-MS: dllexport {{.*}} @"\01??4?$t@D@@QAEAAV0@ABV0@@Z" +// CHECK-MS: dllexport {{.*}} @"\01??4?$s@D@@QAEAAU0@ABU0@@Z" + +// CHECK-IA: dllexport {{.*}} @_ZN1tIcEaSERKS0_ +// CHECK-IA: dllexport {{.*}} @_ZN1sIcEaSERKS0_ +