From Jason Turner

[module.reach]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp2kauw849/{from.md → to.md} +158 -0
tmp/tmp2kauw849/{from.md → to.md} RENAMED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Reachability <a id="module.reach">[[module.reach]]</a>
2
+
3
+ A translation unit U is *necessarily reachable* from a point P if U is a
4
+ module interface unit on which the translation unit containing P has an
5
+ interface dependency, or the translation unit containing P imports U, in
6
+ either case prior to P ([[module.import]]).
7
+
8
+ [*Note 1*: While module interface units are reachable even when they
9
+ are only transitively imported via a non-exported import declaration,
10
+ namespace-scope names from such module interface units are not visible
11
+ to name lookup [[basic.scope.namespace]]. — *end note*]
12
+
13
+ All translation units that are necessarily reachable are *reachable*. It
14
+ is unspecified whether additional translation units on which the point
15
+ within the program has an interface dependency are considered reachable,
16
+ and under what circumstances. [^3]
17
+
18
+ [*Note 2*: It is advisable to avoid depending on the reachability of
19
+ any additional translation units in programs intending to be
20
+ portable. — *end note*]
21
+
22
+ A declaration D is *reachable* if, for any point P in the instantiation
23
+ context [[module.context]],
24
+
25
+ - D appears prior to P in the same translation unit, or
26
+ - D is not discarded [[module.global.frag]], appears in a translation
27
+ unit that is reachable from P, and does not appear within a
28
+ *private-module-fragment*.
29
+
30
+ [*Note 3*: Whether a declaration is exported has no bearing on whether
31
+ it is reachable. — *end note*]
32
+
33
+ The accumulated properties of all reachable declarations of an entity
34
+ within a context determine the behavior of the entity within that
35
+ context.
36
+
37
+ [*Note 4*:
38
+
39
+ These reachable semantic properties include type completeness, type
40
+ definitions, initializers, default arguments of functions or template
41
+ declarations, attributes, visibility of class or enumeration member
42
+ names to ordinary lookup, etc. Since default arguments are evaluated in
43
+ the context of the call expression, the reachable semantic properties of
44
+ the corresponding parameter types apply in that context.
45
+
46
+ [*Example 1*:
47
+
48
+ Translation unit #1
49
+
50
+ ``` cpp
51
+ export module M:A;
52
+ export struct B;
53
+ ```
54
+
55
+ Translation unit #2
56
+
57
+ ``` cpp
58
+ module M:B;
59
+ struct B {
60
+ operator int();
61
+ };
62
+ ```
63
+
64
+ Translation unit #3
65
+
66
+ ``` cpp
67
+ module M:C;
68
+ import :A;
69
+ B b1; // error: no reachable definition of struct B
70
+ ```
71
+
72
+ Translation unit #4
73
+
74
+ ``` cpp
75
+ export module M;
76
+ export import :A;
77
+ import :B;
78
+ B b2;
79
+ export void f(B b = B());
80
+ ```
81
+
82
+ Translation unit #5
83
+
84
+ ``` cpp
85
+ module X;
86
+ import M;
87
+ B b3; // error: no reachable definition of struct B
88
+ void g() { f(); } // error: no reachable definition of struct B
89
+ ```
90
+
91
+ — *end example*]
92
+
93
+ — *end note*]
94
+
95
+ [*Note 5*: An entity can have reachable declarations even if it is not
96
+ visible to name lookup. — *end note*]
97
+
98
+ [*Example 2*:
99
+
100
+ Translation unit #1
101
+
102
+ ``` cpp
103
+ export module A;
104
+ struct X {};
105
+ export using Y = X;
106
+ ```
107
+
108
+ Translation unit #2
109
+
110
+ ``` cpp
111
+ module B;
112
+ import A;
113
+ Y y; // OK, definition of X is reachable
114
+ X x; // error: X not visible to unqualified lookup
115
+ ```
116
+
117
+ — *end example*]
118
+
119
+ <!-- Link reference definitions -->
120
+ [basic.def.odr]: basic.md#basic.def.odr
121
+ [basic.link]: basic.md#basic.link
122
+ [basic.lookup.argdep]: basic.md#basic.lookup.argdep
123
+ [basic.scope.namespace]: basic.md#basic.scope.namespace
124
+ [class.compare.default]: class.md#class.compare.default
125
+ [cpp.import]: cpp.md#cpp.import
126
+ [cpp.include]: cpp.md#cpp.include
127
+ [cpp.pre]: cpp.md#cpp.pre
128
+ [dcl.inline]: dcl.md#dcl.inline
129
+ [dcl.link]: dcl.md#dcl.link
130
+ [dcl.spec.auto]: dcl.md#dcl.spec.auto
131
+ [headers]: library.md#headers
132
+ [lex.name]: lex.md#lex.name
133
+ [lex.phases]: lex.md#lex.phases
134
+ [module]: #module
135
+ [module.context]: #module.context
136
+ [module.global.frag]: #module.global.frag
137
+ [module.import]: #module.import
138
+ [module.interface]: #module.interface
139
+ [module.private.frag]: #module.private.frag
140
+ [module.reach]: #module.reach
141
+ [module.unit]: #module.unit
142
+ [namespace.udecl]: dcl.md#namespace.udecl
143
+ [new.delete.array]: support.md#new.delete.array
144
+ [new.delete.single]: support.md#new.delete.single
145
+ [over.over]: over.md#over.over
146
+ [special]: class.md#special
147
+ [temp.point]: temp.md#temp.point
148
+ [temp.pre]: temp.md#temp.pre
149
+
150
+ [^1]: This is consistent with the rules for visibility of imported names
151
+ [[basic.scope.namespace]].
152
+
153
+ [^2]: A declaration can appear within a *lambda-expression* in the
154
+ initializer of a variable.
155
+
156
+ [^3]: Implementations are therefore not required to prevent the semantic
157
+ effects of additional translation units involved in the compilation
158
+ from being observed.