aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/experimental/ratio
diff options
context:
space:
mode:
authorNathaniel Shead <nathanieloshead@gmail.com>2025-09-10 00:28:36 +1000
committerNathaniel Shead <nathanieloshead@gmail.com>2025-09-10 09:11:09 +1000
commitbdfcb808f8e71158b09313632f919486af52f435 (patch)
treec867f08640be5aa5bd6102d8c4ac770581d14453 /libstdc++-v3/testsuite/experimental/ratio
parenta4db64237d51f2d2ac55cb9d1a73502a904ea478 (diff)
downloadgcc-master.zip
gcc-master.tar.gz
gcc-master.tar.bz2
c++/modules: Cleanup import handling [PR99682]HEADtrunkmaster
This patch fixes some issues with import handling. The main functional change is to allow importing a module's interface file into its implementation file indirectly. [module.import] p9 forbids an explicit 'import M;' declaration, but there's no provision against having 'import X;' where module X itself imports M, so this patch splits up the detection of circular imports to handle this better. I also updated the errors to be closer to the standard wording. A second issue I found while testing this is that we don't properly handle name visibility when a partition implementation unit imports its primary module interface (g++.dg/modules/part-10). This is resolved by setting 'module_p' on the primary interface when it gets imported. Solving this I incidentally removed the assertion that PR121808 was failing on, which was never valid: we can enter import_module for a module previously seen as a module-declaration if parsing bails before declare_module is called. I experimented with guaranteeing that declare_module always gets called for a module_state generated during preprocessing if at all possible, but the resulting errors didn't seem a lot better so I've left it as-is for now. I did make a small adjustment so that a direct import of a module doesn't overwrite the location of a module-declaration from earlier in the file; this is important because preprocessing (and thus the assigning of these locations) seems to happen for the whole file before parsing begins, which can otherwise cause confusing locations referring to later in the file than parsing would otherwise indicate. PR c++/99682 PR c++/121808 gcc/cp/ChangeLog: * module.cc (class module_state): Add comment to 'parent'. (module_state::check_not_purview): Rename to... (module_state::check_circular_import): ...this. Only handle interface dependencies, adjust diagnostic message. (module_state::read_imports): Use new function. Pass location of import as from_loc instead of the module location. (module_state::do_import): Set module_p when importing the primary interface for the current module. (import_module): Split out check for imports in own unit. Remove incorrect assertion. (preprocess_module): Don't overwrite module-decl location with later import. gcc/testsuite/ChangeLog: * g++.dg/modules/circ-1_c.C: Adjust diagnostic. * g++.dg/modules/mod-decl-1.C: Likewise. * g++.dg/modules/mod-decl-2_b.C: Likewise. * g++.dg/modules/pr99174.H: Likewise. * g++.dg/modules/import-3_a.C: New test. * g++.dg/modules/import-3_b.C: New test. * g++.dg/modules/import-3_c.C: New test. * g++.dg/modules/mod-decl-9.C: New test. * g++.dg/modules/part-10_a.C: New test. * g++.dg/modules/part-10_b.C: New test. * g++.dg/modules/part-10_c.C: New test. * g++.dg/modules/part-10_d.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'libstdc++-v3/testsuite/experimental/ratio')
0 files changed, 0 insertions, 0 deletions