[clang] 4fffbc1 - [clang][MSVC] Fix missing MSInheritanceAttr in template specialization.

Zequan Wu via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 14 10:37:44 PST 2021


Author: Zequan Wu
Date: 2021-01-14T10:37:35-08:00
New Revision: 4fffbc150cca1638051b8ad2a20f4b8240df0869

URL: https://github.com/llvm/llvm-project/commit/4fffbc150cca1638051b8ad2a20f4b8240df0869
DIFF: https://github.com/llvm/llvm-project/commit/4fffbc150cca1638051b8ad2a20f4b8240df0869.diff

LOG: [clang][MSVC] Fix missing MSInheritanceAttr in template specialization.

Fix PR48687.

Differential Revision: https://reviews.llvm.org/D94646

Added: 
    

Modified: 
    clang/lib/Sema/SemaTemplate.cpp
    clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 64259767d98a..12880b95b9c6 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -9764,6 +9764,11 @@ DeclResult Sema::ActOnExplicitInstantiation(
       dllExportImportClassTemplateSpecialization(*this, Def);
     }
 
+    if (Def->hasAttr<MSInheritanceAttr>()) {
+      Specialization->addAttr(Def->getAttr<MSInheritanceAttr>());
+      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
index bfe620df5ce3..527363a6ff8f 100644
--- a/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
+++ b/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
@@ -148,6 +148,16 @@ const C table[] = {
 // CHECK-SAME:  %"struct.pr43803::C" { { i32, i32, i32 } { i32 8, i32 0, i32 0 }, [4 x i8] undef }]
 }
 
+namespace pr48687 {
+template <typename T> struct A {
+  T value;
+  static constexpr auto address = &A<T>::value;
+};
+extern template class A<float>;
+template class A<float>;
+// CHECK: @"?address@?$A at M@pr48687@@2QQ12 at MQ12@" = weak_odr dso_local constant i32 0, comdat, align 4
+}
+
 struct PR26313_Y;
 typedef void (PR26313_Y::*PR26313_FUNC)();
 struct PR26313_X {


        


More information about the cfe-commits mailing list