pop_tinst_level ();
if (current_tinst_level)
current_tinst_level->errors = errorcount+sorrycount;
- return level->maybe_get_node ();
+
+ tree decl = level->maybe_get_node ();
+ if (decl && modules_p ())
+ {
+ /* An instantiation is in module purview only if it had an explicit
+ instantiation definition in module purview; mark_decl_instantiated uses
+ set_instantiating_module to set the flag in that case. */
+ if (DECL_MODULE_PURVIEW_P (decl))
+ module_kind |= MK_PURVIEW;
+ else
+ module_kind &= ~MK_PURVIEW;
+ }
+ return decl;
}
/* Returns the TINST_LEVEL which gives the original instantiation
{
mark_definable (result);
mark_needed (result);
+ set_instantiating_module (result);
/* Always make artificials weak. */
if (DECL_ARTIFICIAL (result) && flag_weak)
comdat_linkage (result);
{
int reconsider;
location_t saved_loc = input_location;
+ unsigned saved_module_kind = module_kind;
/* Instantiating templates may trigger vtable generation. This in turn
may require further template instantiations. We place a limit here
while (reconsider);
input_location = saved_loc;
+ module_kind = saved_module_kind;
}
/* Substitute ARGVEC into T, which is a list of initializers for
--- /dev/null
+// PR c++/114630
+// { dg-additional-options "-fmodules-ts -Wno-global-module -fdump-lang-module" }
+// { dg-module-cmi M }
+
+module;
+template <typename> struct allocator {
+ allocator() {}
+};
+template class allocator<wchar_t>;
+
+// Deferred instantiation of GM virtual functions or friend functions
+// should not place newly discovered declarations in the module purview.
+template <typename T>
+void go() {
+ extern T fn_decl();
+}
+template <typename T>
+struct S {
+ friend void x() {}
+ virtual void f() {
+ go<char>();
+ }
+};
+inline S<int> s;
+
+export module M;
+
+// The whole GMF should be discarded here
+// { dg-final { scan-lang-dump "Wrote 0 clusters" module } }
--- /dev/null
+// PR c++/114630
+// { dg-additional-options "-fmodules-ts -Wno-global-module -fdump-lang-module" }
+// { dg-module-cmi M }
+
+module;
+template <typename> struct allocator {
+ allocator() {}
+};
+export module M;
+template class allocator<wchar_t>;
+
+// allocator is reachable because the explicit instantiation is in purview.
+// { dg-final { scan-lang-dump {Wrote declaration[^\n]*allocator} module } }
--- /dev/null
+// PR c++/114630
+// { dg-additional-options "-fmodules-ts -fdump-lang-module" }
+// { dg-module-cmi empty }
+
+module;
+#include "xtreme-header.h"
+export module empty;
+
+// The whole GMF should be discarded here
+// { dg-final { scan-lang-dump "Wrote 0 clusters" module } }
set std_prefix "-std=c++"
global extra_tool_flags
set extra_tool_flags {}
+ global MOD_STD_LIST
foreach op $tmp {
switch [lindex $op 0] {
}
}
- if { !$have_std } {
- global MOD_STD_LIST
+ if { $have_std } {
+ lappend option_list ""
+ } elseif { [string match "*xtreme*" $src] } {
+ # Only run the xtreme tests once.
+ set x [lindex $MOD_STD_LIST end]
+ lappend option_list "${std_prefix}$x"
+ } else {
foreach x $MOD_STD_LIST {
lappend option_list "${std_prefix}$x"
}
- } else {
- lappend option_list ""
}
return $option_list