When an incomplete class specialization is imported, and is completed by
instantiation, we were failing to mark the instantiation, and thus
didn't stream it out. Leading to errors in importing as we had members
of an incomplete type.
PR c++/99389
gcc/cp/
* pt.c (instantiate_class_template_1): Set instantiating module
here.
gcc/testsuite/
* g++.dg/modules/pr99389_a.H: New.
* g++.dg/modules/pr99389_b.C: New.
* g++.dg/modules/pr99389_c.C: New.
--
Nathan Sidwell
diff --git c/gcc/cp/pt.c w/gcc/cp/pt.c
index 83589101c0d..8ca3dc8ec2b 100644
--- c/gcc/cp/pt.c
+++ w/gcc/cp/pt.c
@@ -11816,6 +11816,8 @@ instantiate_class_template_1 (tree type)
input_location = DECL_SOURCE_LOCATION (TYPE_NAME (type)) =
DECL_SOURCE_LOCATION (typedecl);
+ set_instantiating_module (TYPE_NAME (type));
+
TYPE_PACKED (type) = TYPE_PACKED (pattern);
SET_TYPE_ALIGN (type, TYPE_ALIGN (pattern));
TYPE_USER_ALIGN (type) = TYPE_USER_ALIGN (pattern);
diff --git c/gcc/testsuite/g++.dg/modules/pr99389_a.H w/gcc/testsuite/g++.dg/modules/pr99389_a.H
new file mode 100644
index 00000000000..cbb64df7562
--- /dev/null
+++ w/gcc/testsuite/g++.dg/modules/pr99389_a.H
@@ -0,0 +1,20 @@
+// PR 99389 failed to stream class specialization
+// { dg-module-do link }
+// { dg-additional-options "-fmodule-header" }
+// { dg-module-cmi {} }
+template<typename _CharT>
+class basic_string_view
+{
+public:
+ basic_string_view(const _CharT* __str) noexcept
+ {}
+ bool
+ empty() const noexcept
+ { return !_M_len; }
+
+private:
+ unsigned _M_len;
+};
+
+using string_view = basic_string_view<char>;
+
diff --git c/gcc/testsuite/g++.dg/modules/pr99389_b.C w/gcc/testsuite/g++.dg/modules/pr99389_b.C
new file mode 100644
index 00000000000..f8d010e453d
--- /dev/null
+++ w/gcc/testsuite/g++.dg/modules/pr99389_b.C
@@ -0,0 +1,12 @@
+// { dg-additional-options {-fmodules-ts -fdump-lang-module } }
+export module hello;
+// { dg-module-cmi hello }
+
+import "pr99389_a.H";
+
+export inline bool Check (const string_view& n)
+{
+ return !n.empty ();
+}
+
+// { dg-final { scan-lang-dump {Pending specialization '::basic_string_view<char>' entity:. section:. keyed to '::basic_string_view'} module } }
diff --git c/gcc/testsuite/g++.dg/modules/pr99389_c.C w/gcc/testsuite/g++.dg/modules/pr99389_c.C
new file mode 100644
index 00000000000..f31847dd928
--- /dev/null
+++ w/gcc/testsuite/g++.dg/modules/pr99389_c.C
@@ -0,0 +1,7 @@
+// { dg-additional-options -fmodules-ts }
+import hello;
+
+int main ()
+{
+ return Check ("World") ? 0 : 1;
+}