aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl2.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-12-11 11:10:40 -0800
committerNathan Sidwell <nathan@acm.org>2020-12-11 11:15:30 -0800
commit262784be3dcf91a712502b1f4f73e72155171f20 (patch)
tree14271ae9e3e5bc5af0dc299565c458b7627cd6d9 /gcc/cp/decl2.c
parent02fc65c7263c75d222758d6c652b83e543872edf (diff)
downloadgcc-262784be3dcf91a712502b1f4f73e72155171f20.zip
gcc-262784be3dcf91a712502b1f4f73e72155171f20.tar.gz
gcc-262784be3dcf91a712502b1f4f73e72155171f20.tar.bz2
c++: Final module preparations
This adds the final few preparations to drop modules in. I'd missed a couple of changes to core compiler -- a new pair of preprocessor options, and marking the boundary of fixed and lazy global trees. For C++, we need to add module.cc to the GTY scanner. Parsing final cleanups needs a few tweaks for modules. Lambdas used to initialize a global (for instance) get an extra scope, but we now need to point that object to the lambda too. Finally template instantiation needs to do lazy loading before looking at the available instantiations and specializations. gcc/ * gcc.c (cpp_unique_options): Add Mmodules, Mno-modules. * tree-core.h (enum tree_index): Add TI_MODULE_HWM. gcc/cp/ * config-lang.in (gtfiles): Add cp/module.cc. * decl2.c (c_parse_final_cleanups): Add module support. * lambda.c (record_lambda_scope): Call maybe_attach_decl. * module.cc (maybe_attach_decl, lazy_load_specializations): Stubs. (finish_module_procesing): Stub. * pt.c (lookup_template_class_1): Lazy load specializations. (instantiate_template_1): Likewise.
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r--gcc/cp/decl2.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index b13c9d9..6d8158a 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -4964,6 +4964,11 @@ c_parse_final_cleanups (void)
instantiate_pending_templates (retries);
ggc_collect ();
+ if (header_module_p ())
+ /* A header modules initializations are handled in its
+ importer. */
+ continue;
+
/* Write out virtual tables as required. Writing out the
virtual table for a template class may cause the
instantiation of members of that class. If we write out
@@ -5162,6 +5167,8 @@ c_parse_final_cleanups (void)
reconsider = true;
}
+ finish_module_processing (parse_in);
+
lower_var_init ();
generate_mangling_aliases ();
@@ -5177,6 +5184,10 @@ c_parse_final_cleanups (void)
#pragma interface, etc.) we decided not to emit the
definition here. */
&& !DECL_INITIAL (decl)
+ /* A defaulted fn in a header module can be synthesized on
+ demand later. (In non-header modules we should have
+ synthesized it above.) */
+ && !(DECL_DEFAULTED_FN (decl) && header_module_p ())
/* Don't complain if the template was defined. */
&& !(DECL_TEMPLATE_INSTANTIATION (decl)
&& DECL_INITIAL (DECL_TEMPLATE_RESULT
@@ -5210,9 +5221,8 @@ c_parse_final_cleanups (void)
splay_tree_foreach (priority_info_map,
generate_ctor_and_dtor_functions_for_priority,
/*data=*/&locus_at_end_of_parsing);
- else if (c_dialect_objc () && objc_static_init_needed_p ())
- /* If this is obj-c++ and we need a static init, call
- generate_ctor_or_dtor_function. */
+ else if ((c_dialect_objc () && objc_static_init_needed_p ())
+ || module_initializer_kind ())
generate_ctor_or_dtor_function (/*constructor_p=*/true,
DEFAULT_INIT_PRIORITY,
&locus_at_end_of_parsing);