[clang] [clang][ASTImporter] Fix crash when template class static member imported to other translation unit. (PR #68774)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 31 23:37:51 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;
+ }
+ )";
----------------
mzyKi wrote:
Thanks,I have fixed it.
https://github.com/llvm/llvm-project/pull/68774
More information about the cfe-commits
mailing list