From Jason Turner

[module.import]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpfxaaju_b/{from.md → to.md} +145 -0
tmp/tmpfxaaju_b/{from.md → to.md} RENAMED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Import declaration <a id="module.import">[[module.import]]</a>
2
+
3
+ ``` bnf
4
+ module-import-declaration:
5
+ import-keyword module-name attribute-specifier-seqₒₚₜ ';'
6
+ import-keyword module-partition attribute-specifier-seqₒₚₜ ';'
7
+ import-keyword header-name attribute-specifier-seqₒₚₜ ';'
8
+ ```
9
+
10
+ A *module-import-declaration* shall only appear at global namespace
11
+ scope. In a module unit, all *module-import-declaration*s and
12
+ *export-declaration*s exporting *module-import-declaration*s shall
13
+ precede all other *declaration*s in the *declaration-seq* of the
14
+ *translation-unit* and of the *private-module-fragment* (if any). The
15
+ optional *attribute-specifier-seq* appertains to the
16
+ *module-import-declaration*.
17
+
18
+ A *module-import-declaration* *imports* a set of translation units
19
+ determined as described below.
20
+
21
+ [*Note 1*: Namespace-scope names exported by the imported translation
22
+ units become visible [[basic.scope.namespace]] in the importing
23
+ translation unit and declarations within the imported translation units
24
+ become reachable [[module.reach]] in the importing translation unit
25
+ after the import declaration. — *end note*]
26
+
27
+ A *module-import-declaration* that specifies a *module-name* `M` imports
28
+ all module interface units of `M`.
29
+
30
+ A *module-import-declaration* that specifies a *module-partition* shall
31
+ only appear after the *module-declaration* in a module unit of some
32
+ module `M`. Such a declaration imports the so-named module partition of
33
+ `M`.
34
+
35
+ A *module-import-declaration* that specifies a *header-name* `H` imports
36
+ a synthesized *header unit*, which is a translation unit formed by
37
+ applying phases 1 to 7 of translation [[lex.phases]] to the source file
38
+ or header nominated by `H`, which shall not contain a
39
+ *module-declaration*.
40
+
41
+ [*Note 2*: All declarations within a header unit are implicitly
42
+ exported [[module.interface]], and are attached to the global module
43
+ [[module.unit]]. — *end note*]
44
+
45
+ An *importable header* is a member of an *implementation-defined* set of
46
+ headers that includes all importable C++ library headers [[headers]].
47
+ `H` shall identify an importable header. Given two such
48
+ *module-import-declaration*s:
49
+
50
+ - if their *header-name*s identify different headers or source files
51
+ [[cpp.include]], they import distinct header units;
52
+ - otherwise, if they appear in the same translation unit, they import
53
+ the same header unit;
54
+ - otherwise, it is unspecified whether they import the same header unit.
55
+ \[*Note 3*: It is therefore possible that multiple copies exist of
56
+ entities declared with internal linkage in an importable
57
+ header. — *end note*]
58
+
59
+ [*Note 4*: A *module-import-declaration* nominating a *header-name* is
60
+ also recognized by the preprocessor, and results in macros defined at
61
+ the end of phase 4 of translation of the header unit being made visible
62
+ as described in [[cpp.import]]. — *end note*]
63
+
64
+ A declaration of a name with internal linkage is permitted within a
65
+ header unit despite all declarations being implicitly exported
66
+ [[module.interface]].
67
+
68
+ [*Note 5*: A definition that appears in multiple translation units
69
+ cannot in general refer to such names [[basic.def.odr]]. — *end note*]
70
+
71
+ A header unit shall not contain a definition of a non-inline function or
72
+ variable whose name has external linkage.
73
+
74
+ When a *module-import-declaration* imports a translation unit T, it also
75
+ imports all translation units imported by exported
76
+ *module-import-declaration*s in T; such translation units are said to be
77
+ *exported* by T. Additionally, when a *module-import-declaration* in a
78
+ module unit of some module M imports another module unit U of M, it also
79
+ imports all translation units imported by non-exported
80
+ *module-import-declaration*s in the module unit purview of U.[^1] These
81
+ rules may in turn lead to the importation of yet more translation units.
82
+
83
+ A module implementation unit shall not be exported.
84
+
85
+ [*Example 1*:
86
+
87
+ Translation unit #1
88
+
89
+ ``` cpp
90
+ module M:Part;
91
+ ```
92
+
93
+ Translation unit #2
94
+
95
+ ``` cpp
96
+ export module M;
97
+ export import :Part; // error: exported partition :Part is an implementation unit
98
+ ```
99
+
100
+ — *end example*]
101
+
102
+ A module implementation unit of a module `M` that is not a module
103
+ partition shall not contain a *module-import-declaration* nominating
104
+ `M`.
105
+
106
+ [*Example 2*:
107
+
108
+ ``` cpp
109
+ module M;
110
+ import M; // error: cannot import M in its own unit
111
+ ```
112
+
113
+ — *end example*]
114
+
115
+ A translation unit has an *interface dependency* on a translation unit
116
+ `U` if it contains a declaration (possibly a *module-declaration*) that
117
+ imports `U` or if it has an interface dependency on a translation unit
118
+ that has an interface dependency on `U`. A translation unit shall not
119
+ have an interface dependency on itself.
120
+
121
+ [*Example 3*:
122
+
123
+ Interface unit of \`M1\`
124
+
125
+ ``` cpp
126
+ export module M1;
127
+ import M2;
128
+ ```
129
+
130
+ Interface unit of \`M2\`
131
+
132
+ ``` cpp
133
+ export module M2;
134
+ import M3;
135
+ ```
136
+
137
+ Interface unit of \`M3\`
138
+
139
+ ``` cpp
140
+ export module M3;
141
+ import M1; // error: cyclic interface dependency M3 → M1 → M2 → M3
142
+ ```
143
+
144
+ — *end example*]
145
+