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.
This commit is contained in:
Nathan Sidwell 2021-03-05 05:25:54 -08:00
parent 331763de7d
commit 4d66685e49
4 changed files with 41 additions and 0 deletions

View File

@ -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);

View File

@ -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>;

View File

@ -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 } }

View File

@ -0,0 +1,7 @@
// { dg-additional-options -fmodules-ts }
import hello;
int main ()
{
return Check ("World") ? 0 : 1;
}