aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/module.cc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2022-05-09 04:40:43 -0700
committerNathan Sidwell <nathan@acm.org>2022-05-10 04:08:05 -0700
commitd1e8f221e3fc8d3153b662c2f912bf1a26d645ff (patch)
treefe461e95e9e42b16bd7b64c7e757585397ff0b6b /gcc/cp/module.cc
parent76db543db88727789a6c117608a23edc2eace713 (diff)
downloadgcc-d1e8f221e3fc8d3153b662c2f912bf1a26d645ff.zip
gcc-d1e8f221e3fc8d3153b662c2f912bf1a26d645ff.tar.gz
gcc-d1e8f221e3fc8d3153b662c2f912bf1a26d645ff.tar.bz2
[c++] Disambiguate ModuleKind flags
In modules, 'attached to global module' nearly always means 'not in module purview'. Also the implementation treats, 'in global module && in module purview' as meaning 'header unit'. The ModuleKind flags reflected that. The 'nearly always' means there are cases that the first condition is not invariant, and that of course invalidates the second equivalence. This disambiguates the ModuleKind flags to allow that 'not quite', and separate out header-unitness from the GMF & purview flags combination. 1) Separate out named-module vs header-unit from the MODULE/GLOBAL flags. 2) Replace the MODULE/GLOBAL flags with PURVIEW & ATTACH flags. 3) Adjust the parser state handling. Lays ground-work for language-declaration changes. gcc/cp/ * cp-tree.h (enum module_kind_bits): Disambiguate purview, attach, named module vs header-unit. (global_purview_p, not_module_p): Delete. (named_module_p): New. (header_module_p, module_purview_p): Adjust. (module_attach_p, named_module_purview_p): New. * decl.cc (duplicate_decls): Adjust. * module.cc (declare_module, preprocessed_module): Adjust. * name-lookup.cc (init_global_partition): Adjust. (get_fixed_binding_slot, pushdecl): Adjust. * parser.cc (cp_parser_module_declaration): Adjust. (cp_parser_import_declaration, cp_parser_declaration): Adjust.
Diffstat (limited to 'gcc/cp/module.cc')
-rw-r--r--gcc/cp/module.cc29
1 files changed, 13 insertions, 16 deletions
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 6126316..bd4771b 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -18971,25 +18971,21 @@ declare_module (module_state *module, location_t from_loc, bool exporting_p,
gcc_checking_assert (module->is_direct () && module->has_location ());
/* Yer a module, 'arry. */
- module_kind &= ~MK_GLOBAL;
- module_kind |= MK_MODULE;
+ module_kind = module->is_header () ? MK_HEADER : MK_NAMED | MK_ATTACH;
- if (module->is_partition () || exporting_p)
- {
- gcc_checking_assert (module->get_flatname ());
-
- if (module->is_partition ())
- module_kind |= MK_PARTITION;
-
- if (exporting_p)
- {
- module->interface_p = true;
- module_kind |= MK_INTERFACE;
- }
+ // Even in header units, we consider the decls to be purview
+ module_kind |= MK_PURVIEW;
- if (module->is_header ())
- module_kind |= MK_GLOBAL | MK_EXPORTING;
+ if (module->is_partition ())
+ module_kind |= MK_PARTITION;
+ if (exporting_p)
+ {
+ module->interface_p = true;
+ module_kind |= MK_INTERFACE;
+ }
+ if (module_has_cmi_p ())
+ {
/* Copy the importing information we may have already done. We
do not need to separate out the imports that only happen in
the GMF, inspite of what the literal wording of the std
@@ -19523,6 +19519,7 @@ preprocessed_module (cpp_reader *reader)
if (module->is_module ())
{
declare_module (module, cpp_main_loc (reader), true, NULL, reader);
+ module_kind |= MK_EXPORTING;
break;
}
}