Author: Mathias Stearn
Date: 2019-11-08
This change is intended to prevent import
declarations in the global module fragment of a module unit from being implicitly imported when other units of the same module import that unit. Other NB comment resolutions will ensure that such import
declarations must come from #include
expansion (possibly by translation to an import
) and must not be explictlity export
ed.
This is believed to be an unintentional change in behavior from the Modules TS caused by a change in specification mechanisms.
// uses_vector.h
import <vector>; // Could be from a translated #include
// partition.cpp
module;
#include "uses_vector.h" // textually expands to import <vector>;
module A:partition;
// interface.cpp
module A;
import :partition;
std::vector<int> x;
This change makes the last line ill-formed because it refers to std::vector
which is not visible. Previously the import
of <vector>
was implicitly imported into the interface.cpp
translation unit.
Modify 10.3 [module.import] paragraph 6 as follows:
When a module-import-declaration imports a translation unit T, it also imports all translation units imported by exported module-import-declarations in T; such translation units are said to be exported by T. Additionally, w
When a module-import-declaration in a module unit of some moduleM
imports another module unit U ofthe same moduleM
, it also imports all translation units imported by non-exportedallmodule-import-declarations in the module unit purview of Uthat module unit. [ Footnote: This is consistent with the rules for visibility of imported names ([basic.scope.namespace]). — end footnote ] These rules may in turn lead to the importation of yet more translation units.