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:
parent
331763de7d
commit
4d66685e49
@ -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);
|
||||
|
20
gcc/testsuite/g++.dg/modules/pr99389_a.H
Normal file
20
gcc/testsuite/g++.dg/modules/pr99389_a.H
Normal 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>;
|
||||
|
12
gcc/testsuite/g++.dg/modules/pr99389_b.C
Normal file
12
gcc/testsuite/g++.dg/modules/pr99389_b.C
Normal 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 } }
|
7
gcc/testsuite/g++.dg/modules/pr99389_c.C
Normal file
7
gcc/testsuite/g++.dg/modules/pr99389_c.C
Normal file
@ -0,0 +1,7 @@
|
||||
// { dg-additional-options -fmodules-ts }
|
||||
import hello;
|
||||
|
||||
int main ()
|
||||
{
|
||||
return Check ("World") ? 0 : 1;
|
||||
}
|
Loading…
Reference in New Issue
Block a user