From 3b3f2f613e907670a1245e740a582ef011395059 Mon Sep 17 00:00:00 2001 From: Shoaib Meenai Date: Wed, 9 Nov 2016 23:52:20 +0000 Subject: [PATCH] [Sema] Use MS ABI behavior for dllexport in Itanium Similar to r284288, make the Itanium ABI follow MS ABI dllexport semantics in the case of an explicit instantiation declaration followed by a dllexport explicit instantiation definition. Differential Revision: https://reviews.llvm.org/D26471 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@286419 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaTemplate.cpp | 3 ++- test/CodeGenCXX/windows-itanium-dllexport.cpp | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index ce41a5eb74..e87fc73c69 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -7674,7 +7674,8 @@ Sema::ActOnExplicitInstantiation(Scope *S, Def->setTemplateSpecializationKind(TSK); if (!getDLLAttr(Def) && getDLLAttr(Specialization) && - Context.getTargetInfo().getCXXABI().isMicrosoft()) { + (Context.getTargetInfo().getCXXABI().isMicrosoft() || + Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())) { // In the MS ABI, an explicit instantiation definition can add a dll // attribute to a template with a previous instantiation declaration. // MinGW doesn't allow this. diff --git a/test/CodeGenCXX/windows-itanium-dllexport.cpp b/test/CodeGenCXX/windows-itanium-dllexport.cpp index 934c6a2961..2b9b783e03 100644 --- a/test/CodeGenCXX/windows-itanium-dllexport.cpp +++ b/test/CodeGenCXX/windows-itanium-dllexport.cpp @@ -7,3 +7,19 @@ struct __declspec(dllexport) s { // CHECK: define {{.*}} dllexport {{.*}} @_ZN1saSERKS_ // CHECK: define {{.*}} dllexport {{.*}} @_ZN1s1fEv +template +class c { + void f() {} +}; + +template class __declspec(dllexport) c; + +// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIiEaSERKS0_ +// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIiE1fEv + +extern template class c; +template class __declspec(dllexport) c; + +// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIcEaSERKS0_ +// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIcE1fEv + -- 2.40.0