aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2021-03-05 05:25:54 -0800
committerNathan Sidwell <nathan@acm.org>2021-03-05 05:30:30 -0800
commit4d66685e49d20e0c7a87c5fa0757c7eb63ffcdaa (patch)
tree410931856c16fb40085fe89081ec45dbcaeda938 /gcc
parent331763de7d4850702a0f67298f36017c73cdb103 (diff)
downloadgcc-4d66685e49d20e0c7a87c5fa0757c7eb63ffcdaa.zip
gcc-4d66685e49d20e0c7a87c5fa0757c7eb63ffcdaa.tar.gz
gcc-4d66685e49d20e0c7a87c5fa0757c7eb63ffcdaa.tar.bz2
c++: instantiating imported specializations [PR 99389]
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/pt.c2
-rw-r--r--gcc/testsuite/g++.dg/modules/pr99389_a.H20
-rw-r--r--gcc/testsuite/g++.dg/modules/pr99389_b.C12
-rw-r--r--gcc/testsuite/g++.dg/modules/pr99389_c.C7
4 files changed, 41 insertions, 0 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 8358910..8ca3dc8 100644
--- a/gcc/cp/pt.c
+++ b/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 a/gcc/testsuite/g++.dg/modules/pr99389_a.H b/gcc/testsuite/g++.dg/modules/pr99389_a.H
new file mode 100644
index 0000000..cbb64df
--- /dev/null
+++ b/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 a/gcc/testsuite/g++.dg/modules/pr99389_b.C b/gcc/testsuite/g++.dg/modules/pr99389_b.C
new file mode 100644
index 0000000..f8d010e
--- /dev/null
+++ b/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 a/gcc/testsuite/g++.dg/modules/pr99389_c.C b/gcc/testsuite/g++.dg/modules/pr99389_c.C
new file mode 100644
index 0000000..f31847d
--- /dev/null
+++ b/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;
+}