[clang] [clang][ASTImporter] Fix crash when template class static member imported to other translation unit. (PR #68774)

Balázs Kéri via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 27 01:42:43 PDT 2023


================
@@ -1373,6 +1373,40 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportCorrectTemplatedDecl) {
   ASSERT_EQ(ToTemplated1, ToTemplated);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase,
+       ImportTemplateSpecializationStaticMember) {
+  auto FromCode = R"(
+      template <typename H> class Test{
+      public:
+	      static const unsigned int length;
+      };
+
+      template<> const unsigned int Test<int>::length;
+      template<> const unsigned int Test<int>::length = 0;
+      )";
+  auto ToCode = R"(
+    template <typename H> class Test
+    {
+    public:
+	    static const unsigned int length;
+    };
+    template<> const unsigned int Test<int>::length;
+
+    void foo(){
+    int i = 1 / Test<int>::length;
+    }
+    )";
----------------
balazske wrote:

It is better to have the usual code formatting in the test code.

https://github.com/llvm/llvm-project/pull/68774


More information about the cfe-commits mailing list