[c++] Disambiguate ModuleKind flags
authorNathan Sidwell <nathan@acm.org>
Mon, 9 May 2022 11:40:43 +0000 (04:40 -0700)
committerNathan Sidwell <nathan@acm.org>
Tue, 10 May 2022 11:08:05 +0000 (04:08 -0700)
commitd1e8f221e3fc8d3153b662c2f912bf1a26d645ff
treefe461e95e9e42b16bd7b64c7e757585397ff0b6b
parent76db543db88727789a6c117608a23edc2eace713
[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.
gcc/cp/cp-tree.h
gcc/cp/decl.cc
gcc/cp/module.cc
gcc/cp/name-lookup.cc
gcc/cp/parser.cc