diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -9764,6 +9764,12 @@ dllExportImportClassTemplateSpecialization(*this, Def); } + if (Context.getTargetInfo().getCXXABI().isMicrosoft() && + Def->hasAttr()) { + Specialization->addAttr(Def->getAttr()); + Consumer.AssignInheritanceModel(Specialization); + } + // Set the template specialization kind. Make sure it is set before // instantiating the members which will trigger ASTConsumer callbacks. Specialization->setTemplateSpecializationKind(TSK); diff --git a/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp b/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp --- a/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp +++ b/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp @@ -148,6 +148,15 @@ // CHECK-SAME: %"struct.pr43803::C" { { i32, i32, i32 } { i32 8, i32 0, i32 0 }, [4 x i8] undef }] } +namespace pr48687 { +template struct A { + T value; + static constexpr auto address = &A::value; +}; +extern template class A; +template class A; +} + struct PR26313_Y; typedef void (PR26313_Y::*PR26313_FUNC)(); struct PR26313_X {