<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="generator" content="pandoc" />
  <title>P1787R2: Declarations and where to find them</title>
  <style type="text/css">code{white-space: pre;}</style>
  <style type="text/css">
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
  margin: 0; padding: 0; vertical-align: baseline; border: none; }
table.sourceCode { width: 100%; line-height: 100%; }
td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
td.sourceCode { padding-left: 5px; }
code > span.kw { color: #007020; font-weight: bold; }
code > span.dt { color: #902000; }
code > span.dv { color: #40a070; }
code > span.bn { color: #40a070; }
code > span.fl { color: #40a070; }
code > span.ch { color: #4070a0; }
code > span.st { color: #4070a0; }
code > span.co { color: #60a0b0; font-style: italic; }
code > span.ot { color: #007020; }
code > span.al { color: #ff0000; font-weight: bold; }
code > span.fu { color: #06287e; }
code > span.er { color: #ff0000; font-weight: bold; }
  </style>
  <style type="text/css">
  s, .del { background: #ff8888; }
  u, .ins { background: #88ff88; }
  /* from https://stackoverflow.com/a/32456613 */
  body > blockquote {
      display: list-item;
      list-style-type: "- ";
  }
  pre {
  		margin-left: 1.2em;
  }
  </style>
</head>
<body>
<div id="header">
<h1 class="title">P1787R2: Declarations and where to find them<!-- -*- c++-md -*- --></h1>
</div>
<p><em>Audience</em>: CWG<br />S. Davis Herring &lt;<script type="text/javascript">
<!--
h='&#108;&#x61;&#110;&#108;&#46;&#x67;&#x6f;&#118;';a='&#64;';n='&#104;&#x65;&#114;&#114;&#x69;&#110;&#x67;';e=n+a+h;
document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+e+'<\/'+'a'+'>');
// -->
</script><noscript>&#104;&#x65;&#114;&#114;&#x69;&#110;&#x67;&#32;&#x61;&#116;&#32;&#108;&#x61;&#110;&#108;&#32;&#100;&#x6f;&#116;&#32;&#x67;&#x6f;&#118;</noscript>&gt;<br />Los Alamos National Laboratory<br />October 4, 2019</p>
<!--
[basic.link]: CWG1884, CWG2058, CWG278, CWG279, CWG338
[dcl.link]: CWG1713, CWG1817
"hid{ing,den,es}": CWG186, [basic.link]/8, [stmt.dcl]/1, [dcl.decl]/3, [dcl.fct.default]/9, [namespace.udir]/6, /7, [namespace.udecl]/1, /4, /15, [class.name]/2, [class.copy.assign]/8, [class.conv]/5, [class.derived]/2, [class.virtual]/3, [class.base.init]/2, [class.free]/2, [over.dcl]/1, [over.call.object]/2, [over.match.copy]/1.2, [over.match.conv]/1.1, [over.match.ref]/1.1, [over.unary]/2, [over.ass]/1, [over.built]/1, [temp.local]/7, /8, /9
"namespace-?scope": [intro.compliance]/5, [basic.link]/5, /6, [basic.stc.dynamic.allocation]/1, [basic.stc.dynamic.deallocation]/1, [basic.start.main]/1, [basic.start.static]/3, [namespace.def]/1, [namespace.udir]/1, [namespace.udecl]/14, [dcl.link]/6, [class.mfct]/1, [class.ctor]/1.2, [class.dtor]/1.2, [class.static.data]/2, [class.friend]/6, [over.literal]/2, [temp.inject]/2, [except.handle]/12
"block-?scope": CWG473, [basic.start.term]/3, /4, [expr.prim.lambda.closure]/2, [stmt.stmt]/7, [stmt.dcl]/4, /5, [dcl.fct.def.general]/7, [class.union.anon]/2
using-declaration: CWG360, [basic.def]/2.11, [basic.link]/11, [dcl.meaning]/1, [dcl.fct.default]/9, [dcl.enum]/4, [namespace.udecl], [module.interface]/5, [module.global]/2.6, [class]/3, [class.copy.assign]/8, [over.load]/1, [over.match.funcs]/4, [over.literal]/2, [temp.res]/8.5.2
using-directive: [basic.link]/11, [namespace.def]/7, [namespace.udir], [over.load]/1
"[with]in the scope": [expr.prim.lambda.capture]/8, [expr.call]/7, [expr.unary.op]/4, [expr.await]/3.2, [expr.new]/11, /24, [stmt.ranged]/1.3.2, [dcl.meaning]/1, [dcl.init]/13, [dcl.fct.def.coroutine]/6, /9, /10, /12, [dcl.struct.bind]/4, [dcl.enum]/11, [namespace.udir]/2, [namespace.udecl]/18, [class.mfct]/4, [class.static]/2, [class.static.data]/2, [class.nest]/1, [class.union.anon]/1, [class.local]/1, [class.mi]/3, [class.access.spec]/5, [class.friend]/9, [class.base.init]/2, [class.base.init]/15, [class.free]/4, /6, [temp.param]/3, /16, [temp.names]/5, [temp.local]/2, [temp.expl.spec]/8
"in scope": [expr.prim.req]/4, [stmt.select]/2, [stmt.jump]/2, [stmt.dcl]/3, [dcl.dcl]/4, [dcl.fct.default]/9 (twice), [dcl.fct.def.coroutine]/11, [dcl.enum]/11, [class.name]/2, /3, [class.nest]/1, [class.local]/1, [class.friend]/3, [over.dcl]/2, [over.call.func]/3, [temp.over.link]/5, [temp.res]/10, [temp.local]/3, [temp.nondep]/1, [temp.expl.spec]/5
"language linkage": CWG1818, CWG563, [basic.start.main]/3, [dcl.link] (/6 in particular)
"two declarations": CWG2062, CWG1980, [basic.link]/8, [dcl.link]/5, /6
"name lookup": CWG952, CWG1524=CWG591, [expr.prim.lambda.closure]/12, [expr.call]/4, [stmt.label]/1, [dcl.type.elab]/2, [namespace.udir]/2, /6, [namespace.udir]/7, [namespace.udecl]/1, [dcl.attr.grammar]/4, [module.interface]/7, [module.global]/2.3, /3, [module.context]/1, [module.reach]/1, /5, [class.mfct]/11, [class.ctor]/2, [class.static]/3, [class.union.anon]/1, [over.load]/1, [over.call.func]/3, [over.match.oper]/3.2, [temp.names]/2, [temp.arg]/7, [temp.mem]/6, [temp.over.link]/5, [temp.res]/2, [temp.dep]/4, [temp.dep.type]/6.2, /6.3.1, /8, [temp.dep.expr]/3, [temp.nondep]/1, [temp.inst]/17
"typedef": CWG1918, [dcl.typedef]/3, /4, /5, /6, /7, /9, [dcl.type.elab]/2, [module.interface]/5, /6, [class.access]/4
"same-?scope": CWG255, [stmt.label]/1, [dcl.array]/3, [dcl.fct.default]/4, [class.local]/3, [over]/1, [over.load]/1, [over.dcl]/1, /2, [temp]/8, [temp.over.link]/7, [temp.inst]/12, [temp.deduct.guide]/3
"inline namespace set": [dcl.meaning]/1, [dcl.enum]/4, [namespace.def]/2, /8, [class]/3
"global": [basic.life]/6, [basic.stc.dynamic]/1, /2, [basic.stc.dynamic.allocation]/1, /4, [basic.stc.dynamic.deallocation]/1, /3.2, [basic.start.main]/1, /3, [expr.new]/10, /11, /12, /12.3, /24, [expr.delete]/8, /9, [dcl.stc]/1, [dcl.meaning]/1, [dcl.fct.def.coroutine]/9, /10, [dcl.fct.def.coroutine]/12, [namespace.def]/1, [dcl.link]/6, [module.unit]/7.2, [class.mfct]/4, [class.static.data]/2, [class.union.anon]/2, [class.copy.elision]/2, [temp.dep]/4, [temp.inst]/11
"is looked up": [expr.prim.lambda.capture]/4, [expr.await]/3.2, [expr.new]/11, /24, [expr.delete]/9, [dcl.fct.def.coroutine]/9, /10, /12, [dcl.struct.bind]/4, [class.mfct]/4, [class.base.init]/2, [class.free]/4, /6, [over.call.func]/2, /3, [temp.dep.type]/8
"are looked up": [expr.prim.lambda.closure]/4, [stmt.ranged]/1.3.2, /1.3.3, [dcl.fct.default]/5, [dcl.fct.def.coroutine]/6
"translation unit": [basic]/10, [basic.def]/1, [basic.def.odr]/1, /10, /12, [basic.link]/4.1, /4.3, /8, /11.1, [basic.stc.dynamic]/2, [dcl.fct.default]/4, [basic.namespace]/1, /3, [dcl.link]/5, /6, [module.interface]/7, [module.import]/2, [temp]/7
"enclosing": CWG498
"introduc": [basic]/5, [basic.def]/1, [basic.def]/2.5, [basic.def.odr]/9.2, /3, /4, [basic.link]/4, /9, /11, [basic.stc]/2, [basic.stc.dynamic]/2, [expr.prim.lambda.capture]/17, [expr.prim.req]/4, [stmt.iter]/3, [stmt.dcl]/1, /5, [dcl.typedef]/2, [dcl.type.elab]/2, [dcl.spec.auto]/4, [dcl.decl]/3, [dcl.meaning]/1, [dcl.fct.default]/9, [dcl.struct.bind]/1, [dcl.struct.bind]/2, /4, [dcl.enum]/4, [namespace.def]/2, [namespace.udecl]/1, /3, /11, /12, /14, /15, /16, /17, /18, /21, [module.interface]/2.4, /5, /7, [module.global]/2.5.8, [class]/3, [class.name]/2, [class.mem]/3, /5.2, [class.copy.assign]/8, [class.copy.elision]/1.1, [over.match.funcs]/4.2, [temp]/3, [temp.variadic]/8.3, [temp.dep.expr]/3.7, [temp.dep.candidate]/1, [temp.inject]/2
"ignor": [basic.link]/8, [stmt.label]/1, [namespace.udecl]/11, /20, [dcl.link]/4, /6, [class.derived]/2, [over.match.oper]/3.2
"different scopes": [basic.link]/11, [dcl.fct.default]/4
"access control": [class.access]/4, [over.dcl]/3
"multiple declarations": [basic.link]/11, [namespace.udecl]/10, [over.match.best]/4
"primary template name": [temp.class.spec]/7
"intervening": [basic.def.odr]/9.2, [expr.prim.lambda.capture]/7, [namespace.def]/8
"extend[ed/s]": [stmt.while]/2, [stmt.for]/3, [namespace.def]/2, /5, /6, [namespace.udir]/5, [class.copy.elision]/1.2, /3.2, [except.handle]/11, [cpp.replace]/10
"satisf" (because of the duplication between name lookup and overload resolution): [over.match.viable]/3, [over.over]/4, [temp.inst]/17
"overload": CWG1499, CWG1252, CWG1898, CWG1038, [basic.def.odr]/3.1, /3.2, [basic.start.main]/2, [expr.unary.op]/6, [dcl.stc]/6, [dcl.type.decltype]/1.3, [namespace.udecl]/18, [module.global]/2.4, [class.access]/4, [over.dcl]/3, [over.match.call]/1, /2, [over.over]/1, [temp.names]/2, [temp.arg]/7, [temp.arg.nontype]/2.5, [temp.inst]/9, [temp.deduct.call]/6.1, /6.2, [temp.deduct.funcaddr]/1, [temp.deduct.type]/5.5, [temp.over]/1, [except.spec]/13.1
"all declarations": [basic.link]/12, [basic.link]/13, [dcl.fct]/10
"placed in the namespace": CWG1602 (why does it even matter what namespace they're in?), [temp.inst]/11, [temp.explicit]/7
"redeclar": CWG157, CWG1896, CWG1729 (#4/#5), [basic.def]/1, [basic.link]/8, /12, [stmt.label]/1, [stmt.iter]/3, [dcl.dcl]/5, [dcl.typedef]/3, /4, /5, /6, [dcl.spec.auto]/13, [dcl.fct.default]/9, [dcl.enum]/3, [namespace.def]/4, [dcl.attr.deprecated]/3, [dcl.attr.unused]/4, [module.interface]/6, /7, /8, [module.global]/2.5.2, [class.name]/2, [class.mem]/5.2, [class.mfct]/1, [class.static.data]/3, [class.derived]/2, [class.access.spec]/4, [temp.class]/4, [temp.friend]/1.4, /4, [temp.local]/6, [temp.inst]/2
"any declaration": CWG1617=CWG2223, [dcl.align]/6
"reaching scope": (none)
"match": CWG1001 vs. CWG1322, CWG2037, CWG1665, CWG2, [basic.def.odr]/3.2, [basic.link]/8, [expr.new]/16, /23, /25, [over.dcl], [temp.class]/3, [temp.mem.func]/1, [temp.mem]/1, [temp.friend]/1.2, [temp.func.order]/1.3, [temp.explicit]/5, [temp.deduct.decl]/1, [except.ctor]/5
"deallocation": CWG255, CWG1628, [basic.def.odr]/3.2, [expr.new]/24, /25, [expr.delete]/9, /10, /12, [dcl.fct.def.coroutine]/12, [class.dtor]/5.3, /13, [class.free]/4, /6, [temp.func.order]/1.3, [temp.deduct.decl]/1, [except.ctor]/5
"complete": CWG1092, IS...
"dependent": CWG2065, IS...
"nested-name-specifier": CWG536, IS...
CWG1172 (what depends on a template parameter for purposes of equivalence?)


[basic.lookup.qual]/6 (and many other places): "in the scope of C" and "in the scope of the postfix-expression" are very different
D1103R3's [basic.link]/10 prevents the required diagnostic in /11 (in many cases, at least); maybe rephrase in terms of just "redeclaration", since that _should_ only apply when the previous is reachable (but "reachable redeclarations" in [basic.lookup]/1 is fine)
diagnose [basic.link] collisions where possible (part of CWG1884)
[basic.link]/12: friend declarations should be able to reach across modules
Add blanket wording vs. redeclaring non-namespace-scope variables/functions and typedefs
[expr.prim.id]/2: this is a good place for this, but wasn't it somewhere else too?
[expr.prim.id]/5: universal overload resolution plz; can a function whose constraints are not met be recursive?
[dcl.dcl]/5: describes being in a scope and creating more scopes
[dcl.spec.auto]/13, [dcl.fct]/10: limits what counts as a redeclaration
[dcl.fct]/10: "several different functions in a single scope"
[dcl.struct.bind]/4: does ADL without doing unqualified lookup
[class]/1: "its scope"
[class]/2: "the scope in which it is declared", "the scope of the class itself"
[class.mem]/5 prohibits redeclaring class members (except for forward declarations of classes and enumerations)
[class.this]/3: should be redundant with overload resolution (if we applied viability to single lookup results); the whole subclause could probably go
[class.dtor]/1.2: can this be unified with the rule for calling a destructor?
Should a namespace name clash with a non-namespace name in another TU?
[class.union.anon]/2: redundant with something earlier about declaring namespace-scope anonymous unions static

the phrases "has namespace scope" and maybe "at namespace scope" should go
Use "match" for [basic.link]/8's "would be a (possibly ill-formed) redeclaration" and [namespace.udecl]/14; note that "int f(); void f();" can either be said to match (because they're not templates) and violate a rule about the same type, or be said to not match (which might read better) and violate an overloading rule; note the related case of "int f(); namespace f {}", where it's not overloading that's being violated; "redeclare" is also used to mean "declare the same name (to have a different meaning)", but we should probably use something else (perhaps "is a conflicting declaration of (foo)")
Should we say that we redeclare declarations, or the names and entities they declare?  Why would an explicit specialization also be considered a redeclaration ([class.mfct]/1)?
"not in scope" -> "not found" (but that doesn't seem dynamic)
A note would be good about how "X A::B(X)" looks up the two Xs differently but does access control on them in the same way.
Is it a good or bad idea to have objects have scope (e.g., "block-scope object/variable")?
Careful about declaring names to refer to entities vs. declaring entities to have names
[dcl.link]/6: extern "C" identifies functions and variables (with C++ global-namespace variables) across namespaces
Lookup for a normal function call should cleanly precede overload resolution, not be specified in it ([over.call.func]/3), partly because it is possible to construct overload sets not by name lookup (e.g., when considering conversion functions or constructors).  Add a note: "Name lookup is finished even if none of the lookup results are viable.".
Maybe we can get rid of "global object"
Need to make sure that universal overload resolution doesn't cause functions to decay to pointers (e.g., because of default arguments)

Linkage:
per-overload linkage (ideally, entity-based linkage ([lex.separate]/2)), but each template is but one entity, and "static typedef" can't be seen via import
It would be nice to get rid of module linkage entirely (and just use exportedness), but watch out for [temp.dep.candidate]/1's usage of external linkage.
Can we replace "no linkage" with its more-linker-like value?  (E.g., for [module.interface]/7.)
Is it OK for a (de)allocation function to have module linkage?
[class.mfct]/2 and [class.static.data]/5 reiterate that class members have linkage

Language linkage:
How does the ODR treat definitions of C-language-linkage functions in different namespaces?
Can we do without language linkage for _names_ (especially for irrelevant things like class members?)


-->

<h1 id="history">History</h1>
<p>r2:</p>
<ul>
<li>Rebased onto N4830 (significant for <code>using</code> enumerators/enumerations)</li>
<li>Added a locus for a <em>concept-definition</em></li>
<li>Extended containing scopes into redeclarations of classes and enumerations</li>
<li>Properly limited cross-TU qualified lookup in namespaces</li>
<li>Fixed rules for conflicts between <em>using-declaration</em>⁠s</li>
<li>Renamed “anonymous union object” to “anonymous union variable”</li>
</ul>
<p>r1:</p>
<ul>
<li>Fixed reversed <em>using-directive</em> containment test</li>
<li>Updated <strong>signature</strong> definitions</li>
<li>Removed residual “point of declaration” usage</li>
<li>Fixed several uses of (new) “precede” to be (existing) “reachable”</li>
<li>Removed dangling “considered to refer to a template” reference</li>
<li>Used “be attached” for modules instead of (new, unrelated) “belong”</li>
<li>Included class templates with classes for all scope purposes</li>
<li>Distinguished entities from their associated scopes</li>
<li>Accounted for missing kinds of declarations</li>
<li>Removed superfluous definition of “denotes”</li>
<li>Disentangled “enclose” and “contain” definitions</li>
<li>Specified no lookup for <code>X</code> in <code>using X=...;</code></li>
<li>Allowed a <em>namespace-name</em> to be a member-qualified name</li>
<li>Allowed in-class lookup of <code>X</code> in <code>p-&gt;~X()</code> and <code>decltype(...)::~X()</code></li>
<li>Ignored non-type <code>X</code> in <code>struct N::X x;</code></li>
<li>Limited <code>this</code>/<code>static</code> prohibition with “current class”</li>
<li>Deprecated <code>A::template B</code> (as a template template argument or CTAD placeholder)</li>
<li>Allowed forward declarations of partial specializations</li>
<li>Removed mention of resolved issue</li>
<li>Added explanatory examples to aid review</li>
</ul>
<h1 id="introduction">Introduction</h1>
<p>The current descriptions of scope and name lookup are confusing, incomplete, and at times incorrect. [basic.scope] defines the word “scope” in two different ways, and then implicitly and indirectly specifies many aspects of name lookup with imperfect correspondence to the descriptions in [basic.lookup]. Lookup is often described for units of program text that may include multiple names and <code>&lt;</code> tokens that must be disambiguated, such as a <em>template-id</em> ([temp.dep]/2), <em>id-expression</em> ([over.call.func]/2), or <em>conversion-type-id</em> ([class.qual]/1.2). Namespaces, and the global namespace in particular, are inconsistently described as being one or many declarative regions ([basic.scope.namespace]/1, /4). There are dozens of Core issues (discussed individually <a href="#issues">below</a>) on the subject; the general vagueness of the wording on the subject interferes with resolving them individually.</p>
<p>Modules significantly complicate the situation, principally by invalidating the tacit assumption that “every” lookup is restricted to preceding declarations in the same translation unit. There were already exceptions to that rule (<em>e.g.</em>, complete class contexts and <a href="http://wiki.edg.com/pub/Wg21cologne2019/CoreWorkingGroup/cwgMMMM.html"><em>using-declaration</em> conflicts</a>), which can then easily be (mis)read as applying to all contents of all translation units. Other rules, like those for lookup through a <em>using-directive</em>, that do not make any mention of location may now plausibly be read as being available through an <code>import</code>.</p>
<!-- TODO: discuss redeclarations? -->

<p>This paper rewrites large sections of [basic.scope] and [basic.lookup] and parts of [temp.res] (and makes the requisite changes elsewhere to adapt to new definitions) to address these issues holistically. 50 Core issues are resolved, as well as 14 points discussed on the reflector but not (yet) on the issues list. Many changes are (collectively) editorial, but their very number demands CWG review. Other changes generally formalize current implementation practice or, in the absence of implementation consensus, establish language consistency.</p>
<h1 id="approach">Approach</h1>
<p>To avoid redundant specification of scope and of name lookup, all description of where a name might be used ([basic.scope.block], [basic.scope.enum], <em>etc.</em>) is phrased merely in terms of the total extent of each scope where a name might be introduced. The scopes are always properly nested, although there are situations where unqualified lookup considers a scope that does not contain the point of the lookup. <!-- These are marked with "non-nested" in a comment. --> Explicit wording is introduced to require that lookup occur from a program point (replacing lookup “in the context” of something) and consider only previous declarations (except in complete-class contexts) and those made available by <code>import</code>. Most declarations are said to “bind” the names they introduce to themselves, replacing the notion of “not found by lookup”. To avoid confusion, the word “bind” is not used for describing locked-in lookup results as for default arguments (which can instead be described as being looked up from their declarations). The use of the word “visible” to indicate a declaration’s placement is avoided in normative text.</p>
<p>Several kinds of scope search are defined, and several kinds of qualified lookup are combined, to minimize redundancy in the definition of the lookup algorithms. The word “lookup” or phrase “look up” is used only for resolution of a name that is complete (at least in the simple context; it might be reused as a subroutine elsewhere).</p>
<p>The descriptions of the algorithms generally favor local completeness at the expense of additional references to distant clauses (that would otherwise specify special cases for their respective language features). <!-- Exceptions are indicated by "remote" in a comment. --> Several rule restatements are turned into notes.</p>
<p>Every lookup is explicitly for a name, not an <em>id-expression</em> or <em>type-id</em>. Template arguments in an <em>id-expression</em> are addressed by defining which names are subject to qualified lookup and by excluding a <em>template-id</em> from being a name. Because labels interact with so little of the language, their identifiers are excluded from names and name lookup entirely.</p>
<p>To avoid confusion when a name is declared multiple times in a scope, careful distinction is made between a name and a declaration of that name. In particular, the “point of declaration” of a name (usually; [basic.scope.pdecl]/3 describes one for an anonymous class or enumeration) is replaced with the “locus” of a declaration.</p>
<p>The phrase “global name” is removed to reduce the apparent special status of the global namespace (but “global scope” still exists because of its lack of syntax and as a shorthand).</p>
<p>Wording for the (possible) declaration of a class by an <em>elaborated-type-specifier</em> is removed from [basic.scope.pdecl]/7, [basic.lookup.elab]/2, [namespace.memdef]/3, and [class.friend]/11 and merged into [dcl.type.elab].</p>
<p>Richard’s proposal for <a href="http://lists.isocpp.org/core/2019/03/5795.php">“using-declarations &amp; {,!}export”</a> is followed: a (non-dependent) <em>using-declaration</em> is replaced with its referent(s) during name lookup rather than introducing additional declarations. Because it is consistent with that replacement, and for consistency with existing implementations, the inclusion of hidden type names by a member <em>using-declaration</em> is extended to those not in a class.</p>
<h2 id="examples">Examples</h2>
<p>The lookup for the following examples is narrated to help CWG members relate old and new terminology. Cross references prefixed with + are to N4830 as edited here.</p>
<h3 id="using-directive-vs.-using-declaration"><em>using-directive</em> vs. <em>using-declaration</em></h3>
<pre class="sourceCode cpp"><code class="sourceCode cpp"><span class="kw">namespace</span> F {<span class="dt">float</span> x;}
<span class="kw">namespace</span> A {
  <span class="kw">namespace</span> I {<span class="dt">int</span> x;}
  <span class="kw">using</span> <span class="kw">namespace</span> I;
  <span class="kw">using</span> F::x;
  <span class="dt">void</span> f() {
    x=<span class="dv">0</span>;     <span class="co">// #1: error</span>
    A::x=<span class="dv">1</span>;  <span class="co">// #2: OK: F::x</span>
  }
}</code></pre>
<ol style="list-style-type: decimal">
<li>At #1, <code>x</code> is looked up as an unqualified name (+[basic.lookup.unqual]/4) via an unqualified search of the function parameter scope of <code>A::f</code> (/3).</li>
<li>When continuing on to the namespace scope of <code>A</code>, the unqualified search searches <code>A</code> and also every namespace contained by <code>A</code> and nominated by an active <em>using-directive</em> (/2).</li>
<li>The single <em>using-directive</em> is active in the function parameter scope (/1), which is contained by <code>A</code>, as is <code>I</code>.</li>
<li>Therefore <code>A</code> and <code>I</code> are searched simultaneously.</li>
<li>The <em>using-declaration</em> is replaced with <code>F::x</code> (+[basic.lookup]/5), and the lookup is ambiguous ([basic.lookup]/1).</li>
</ol>
<!-- two lists -->

<ol style="list-style-type: decimal">
<li>At #2, <code>A</code> is looked up as an unqualified name. <code>x</code> is a qualified name (+[basic.lookup.qual]/2), so undergoes qualified name lookup (/3) which is just a search of <code>A</code>.</li>
<li>The search finds <code>F::x</code>, so the <em>using-directive</em> is not considered by +[namespace.qual]/1.</li>
</ol>
<h3 id="cwg459"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#459">CWG459</a></h3>
<pre class="sourceCode cpp"><code class="sourceCode cpp"><span class="kw">struct</span> A {<span class="kw">using</span> T=<span class="dt">int</span>;};  <span class="co">// given</span>
<span class="kw">template</span>&lt;<span class="kw">class</span> T&gt;
<span class="kw">struct</span> B : A {
  <span class="dt">void</span> f() {T i;}
};</code></pre>
<ol style="list-style-type: decimal">
<li><code>T</code> (in the <em>template-head</em>), <code>B</code>, and <code>f</code> are not looked up (+[dcl.meaning]/3, +[class]/1).</li>
<li><code>A</code> is looked up as an unqualified name (+[basic.lookup.unqual]/4), ignoring non-type names ([class.derived]/2).</li>
<li><code>T</code> is looked up as an unqualified name when defining the class template <code>B</code> (+[temp.res]/1):
<ol style="list-style-type: decimal">
<li>Unqualified name lookup performs an unqualified search in the enclosing scope (+[basic.lookup.unqual]/3), which is the function parameter scope of <code>B::f</code> (+[basic.scope.param]/1, +[basic.scope.block]/2).</li>
<li>For each enclosing scope, an unqualified search is just a search except when considering a namespace (+[basic.lookup.unqual]/2); a search is just a single search except when considering a class (template) (+[class.member.lookup]/1). The function parameter scope is neither and has no binding for <code>T</code> (it has only <code>__func__</code>).</li>
<li>The next enclosing scope is that of <code>B</code>; classes and class templates have scopes (+[basic.scope.class]/1). It is a class template, and a single search in it finds nothing ([class.member.lookup]/4), so its non-dependent base classes are considered (+[class.member.lookup]/5).</li>
<li>A single search in the scope of <code>A</code> finds the <em>typedef-name</em>.</li>
<li>The next enclosing scope is the template parameter scope to which the template parameter <code>T</code> belongs ([basic.scope.temp]/2), but it is never considered.</li>
</ol></li>
</ol>
<h3 id="calling-a-conversion-function">Calling a conversion function</h3>
<pre class="sourceCode cpp"><code class="sourceCode cpp"><span class="dt">auto</span> x = s.<span class="kw">operator</span> R T::*();</code></pre>
<ol style="list-style-type: decimal">
<li><code>x</code> is not looked up (+[dcl.meaning]/3).</li>
<li><code>s</code> is subject to normal unqualified lookup (+[basic.lookup.unqual]/4).</li>
<li>The names used in the <em>conversion-type-id</em> are looked up “in the same fashion as the <em>conversion-function-id</em>” (/5).</li>
<li>While that lookup can’t happen yet, the <em>conversion-function-id</em> is a member-qualified name (+[basic.lookup.qual]/2) and thus undergoes qualified lookup in the class of <code>s</code> (call it <code>S</code>; /3).</li>
<li>If <code>S::R</code> finds nothing, <code>R</code> is looked up as an unqualified name (+[basic.lookup.unqual]/5 again); <code>T</code> is considered the same way (separately), except that non-type names are ignored because of the following <code>::</code> ([basic.lookup.qual]/1).</li>
<li>Once the type named by the <em>conversion-type-id</em> is known ([class.conv.fct]/1), the <em>conversion-function-id</em> is looked up as described above.</li>
</ol>
<h3 id="calling-destructors">Calling destructors</h3>
<pre class="sourceCode cpp"><code class="sourceCode cpp"><span class="kw">struct</span> A {<span class="kw">using</span> X=A;} a;
<span class="kw">struct</span> B : A {<span class="kw">struct</span> X {};};
<span class="dt">void</span> f(B *b) {
  b-&gt;A::~X();            <span class="co">// #1: error</span>
  b-&gt;<span class="kw">decltype</span>(a)::~X();  <span class="co">// #2: OK</span>
}</code></pre>
<ol style="list-style-type: decimal">
<li>At #1, <code>A</code> undergoes qualified lookup in <code>B</code> (+[basic.lookup.qual]/3).</li>
<li>Because its <em>nested-name-specifier</em> is a (member-)qualified name (/2), <code>X</code> is looked up as <code>A</code> was (/5.1.2), which finds <code>B::X</code>.</li>
<li><p>Since that is not the lookup context <code>A</code>, <code>X</code> is then tried as an unqualified name (/5.2), but that finds nothing.</p></li>
<li>At #2, the <em>nested-name-specifier</em> for the qualified name containing <code>X</code> is not itself a qualified name (nor a name of any kind), so <code>X</code> is looked up as a normal terminal name (/5.1).</li>
<li><p>Since <code>decltype(a)</code> refers to <code>A</code>, it is <code>A::X</code> that is found.</p></li>
</ol>
<h1 id="issues">Issues</h1>
<h2 id="definitions">Definitions</h2>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#554">CWG554</a> is resolved by using the word “scope” <em>instead of</em> “declarative region”, consistent with its very common use in phrases like “namespace scope”. The other uses of “scope” are implied by the explicit unqualified lookup algorithm. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2165">CWG2165</a> is resolved by removing the conflicting definition of it in [basic.scope].</p>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#405">CWG405</a> is resolved by stating that argument-dependent lookup (sometimes) occurs after an ordinary unqualified lookup (making statements like “finding a variable prevents argument-dependent lookup” formally correct).</p>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#36">CWG36</a> (which has the dubious distinction of having the earliest recorded date) is resolved by limiting the restriction in question to class scopes, where ambiguous accessibility would be a problem, since a <em>using-declaration</em> does not introduce declarations. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#418">CWG418</a> is resolved by trivial rephrasing along with that necessary for the new <em>using-declaration</em> interpretation.</p>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1291">CWG1291</a> and <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2396">CWG2396</a> are resolved by explicitly specifying how to look up names in a <em>conversion-type-id</em>.</p>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#600">CWG600</a> is resolved by explaining that accessibility affects naming a member in the sense of the ODR.</p>
<h2 id="lookup-completeness">Lookup completeness</h2>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#191">CWG191</a> and <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1200">CWG1200</a> are resolved by defining unqualified lookup in terms of every enclosing scope. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#536">CWG536</a> (long partially resolved) is resolved by specifying that unqualified lookup occurs for any kind of <em>unqualified-id</em> as an <em>id-expression</em>. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#399">CWG399</a> is resolved by explicitly appealing to the lookup for the last component of any suitable <em>nested-name-specifier</em>. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#562">CWG562</a> is resolved by defining lookup as occurring from a program point.</p>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1906">CWG1906</a> (currently closed as NAD, perhaps because its proposed resolution suffered in attempting to fit the structure of [basic.lookup.unqual] rejected by CWG191) and <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2370">CWG2370</a> are resolved by Rachel’s regularization suggested in <a href="http://lists.isocpp.org/core/2019/05/6461.php">“Reconsidering CWG1906 and its friend CWG2370”</a>, which may be in conflict with the <a href="http://wiki.edg.com/bin/view/Wg21sandiego2018/CoreWorkingGroup#Core_issue_2370_friend_declarati">CWG opinion from San Diego</a>.</p>
<p>My proposed simplification for <a href="http://lists.isocpp.org/core/2019/03/5681.php">“Missing associated namespace for member template template arguments?”</a> is incorporated on the assumption that the failure to examine the namespace of an associated class is an oversight. (GCC and ICC, but not Clang or MSVC, accept the example in that message.)</p>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1822">CWG1822</a> is resolved by specifying that the body of a lambda remains in the surrounding (function parameter) scope.</p>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1894">CWG1894</a> and its duplicate <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2199">CWG2199</a> are resolved per Richard’s proposal for <a href="https://listarchives.isocpp.org/cgi-bin/wg21/message?wg=core&amp;msg=28415">“dr407 still leaves open questions about typedef / tag hiding”</a>, using generic conflicting-declaration rules even for <code>typedef</code>, and discarding a redundant <em>typedef-name</em> when looking up an <em>elaborated-type-specifier</em>.</p>
<p>[namespace.udir]/5 is simply removed; careful backward-lookup rules already allow such usage, and no implementation actually delays any declarations until the end of a <em>namespace-definition</em>.</p>
<p>Jens’ interpretation of <a href="http://lists.isocpp.org/core/2019/04/6024.php">“On beyond CWG372”</a> is included as a note (<em>cf.</em> Richard’s <a href="http://lists.isocpp.org/core/2019/04/6026.php">proposed restriction</a>)<!-- FIXME: which would obviate the need for the *base-specifier* note -->. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#607">CWG607</a> is resolved by looking up unqualified names in a <em>mem-initializer-id</em> from outside the parameter scope. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1837">CWG1837</a> is resolved by restricting <code>this</code> to referring to the innermost enclosing class.</p>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2007">CWG2007</a> is resolved by skipping unqualified lookup for operators that must be member functions.</p>
<p>Richard’s correction to template parameter scope for constrained template template parameters for <a href="http://lists.isocpp.org/core/2019/05/6122.php">“CWG186 is NAD (or ‘Resolved’)”</a> is incorporated.</p>
<p>The missing point of declaration for a concept identified by Andrew in <a href="https://lists.isocpp.org/core/2019/09/7238.php">“recursive concepts”</a> is supplied (without any prohibition on self-referential concepts).</p>
<h2 id="complete-class-context">Complete-class context</h2>
<p>The intent for <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2335">CWG2335</a> (contra those of the older <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1890">CWG1890</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1626">CWG1626</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1255">CWG1255</a>, and <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#287">CWG287</a>) is supported by retaining the unrestricted forward lookup in complete-class contexts (despite current implementation behavior for non-templates). <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#361">CWG361</a> is partially resolved by that confirmation; the rest must be addressed along with CWG2335. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2331">CWG2331</a> is resolved by defining lookup from complete-class contexts and out-of-line member definitions. The rest of <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2009">CWG2009</a> is resolved by making it ill-formed NDR for forward lookup outside a complete-class context to change the results (before overload resolution, to avoid differences in instantiation). <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#325">CWG325</a> is resolved by preventing forward lookup while first parsing a class from producing a <em>template-id</em> (and relying on the CWG2009 resolution to ban a change of interpretation) while generalizing the <code>template</code> prefix to support lookup in an incomplete class. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1635">CWG1635</a> is partially resolved by also making template default arguments a complete-class context.</p>
<h2 id="declaration-matching">Declaration matching</h2>
<p>My clarification in <a href="http://lists.isocpp.org/core/2019/06/6614.php">“Where can namespace-scope functions and variables be redeclared?”</a> is applied, resolving <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1821">CWG1821</a>.</p>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1820">CWG1820</a> is resolved by requiring that a qualified <em>declarator-id</em> declare an entity. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#386">CWG386</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1839">CWG1839</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1900">CWG1900</a>, and Richard’s observation in <a href="http://lists.isocpp.org/core/2017/01/1604.php">“are non-type names ignored in a class-head-name or enum-head-name?”</a> are resolved by describing the limited lookup that occurs for a <em>declarator-id</em>, including the changes in Richard’s <a href="http://wiki.edg.com/pub/Wg21cologne2019/CoreWorkingGroup/cwg1839.html">proposed resolution for CWG1839</a> and rejecting the example from <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1477">CWG1477</a>. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#138">CWG138</a> is resolved according to <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2000/n1229.html">N1229</a>.</p>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#110">CWG110</a> is resolved by reducing the restriction in [temp] to a note (matching the behavior of GCC, Clang, and ICC).</p>
<h2 id="modules">Modules</h2>
<p>Richard’s proposed resolution for <a href="http://lists.isocpp.org/core/2019/04/6014.php">“missing restriction on private-module-fragment”</a> is incorporated.</p>
<p>Nathan’s question about <code>export using</code> in <a href="http://lists.isocpp.org/core/2019/03/5773.php">“using-declarations &amp; {,!}export”</a> is avoided by not introducing synonyms that might or might not be exported. Richard’s <a href="http://wiki.edg.com/pub/Wg21cologne2019/CoreWorkingGroup/cwgMMMM.html">issue submission for <em>using-declaration</em> conflicts</a> is resolved by combining the generic notions of “conflicts with” and “precedes”.</p>
<p>Nothing is done about P1498R1, since its solution does not involve name lookup. For example, the intent is to disallow lookups that use a <a href="http://lists.isocpp.org/core/2019/03/5773.php"><em>using-declaration</em> that names a declaration of a name with internal linkage</a> rather than the <em>using-declaration</em> itself.</p>
<h2 id="parsing">Parsing</h2>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1771">CWG1771</a> is resolved by describing the lookup of only an <em>identifier</em>, or (per my proposal in <a href="https://lists.isocpp.org/core/2019/06/6564.php">“‘Down with template!’”</a>) the name in a recognized <em>template-id</em> (whether or not dependent), preceding a <code>::</code>. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1828">CWG1828</a> is resolved by disfavoring the interpretation of <code>::</code> as an entire <em>nested-name-specifier</em>.</p>
<p>My proposal for <a href="https://lists.isocpp.org/core/2019/05/6171.php">“‘Down with template!’”</a> is incorporated by generalizing “type-id-only context” to “type-only context” and applying it to <code>template</code> as well as <code>typename</code>. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1835">CWG1835</a> is resolved by removing the special provision for <code>-&gt;</code>/<code>.</code> <em>identifier</em> <code>&lt;</code> in [basic.lookup.classref]/1, requiring that <code>template</code> be used to refer even to a non-member template in that position. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1908">CWG1908</a> is resolved per its suggestion of performing qualified lookup first and stopping if it produces a <em>template-id</em>, always taking <code>&lt;</code> to indicate one (per Richard’s proposal for <a href="http://lists.isocpp.org/core/2019/04/6042.php">“On beyond CWG1908”</a>). My further <a href="http://lists.isocpp.org/core/2019/04/6074.php">proposal</a> for parsing a <em>qualified-id</em> in a dependent class member access is applied. My proposal for <a href="http://lists.isocpp.org/core/2019/05/6257.php">“grammar ambiguities with non-simple template-ids”</a> is applied, allowing any kind of name to be considered to refer to a template, except for a <em>conversion-function-id</em> for which the rules would be more complicated despite never applying. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1841">CWG1841</a> is resolved by considering the injected-class-name of a class template to refer to a template.</p>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1616">CWG1616</a> is resolved by explicitly characterizing the forbidden case in terms of lookup results.</p>
<h2 id="templates">Templates</h2>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#459">CWG459</a> is not affected: base classes are still searched in unqualified lookup before template parameters are considered.</p>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1936">CWG1936</a> is resolved by expanding the definition of “dependent name” to include qualified names (<em>i.e.</em>, names previously said to be “a member of an unknown specialization”). <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1500">CWG1500</a> is resolved by further expanding it to include any <em>conversion-function-id</em> with a dependent type (and clarifying that dependent lookup takes place after substitution). My proposed regularization of <em>conversion-type-id</em> interpretation (which includes resolving <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2413">CWG2413</a>) in <a href="http://lists.isocpp.org/core/2019/05/6178.php">“‘Down with template!’”</a> and proposed rule for considering conversion function templates in <a href="http://lists.isocpp.org/core/2019/05/6339.php">“When are conversion function templates hidden?”</a> are incorporated. The assumption that a qualified dependent name names a type is disabled inside a <code>decltype</code> or array bound. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1028">CWG1028</a> is resolved by moving the “lookup from first declaration” rule from [temp.over.link]/5 to [temp.res]/1. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1907">CWG1907</a> is resolved by forbidding dependence on default (template) arguments not found by <em>lookup</em> for a dependent name.</p>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1829">CWG1829</a> is resolved by checking for direct members of a class that is the current instantiation.</p>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1089">CWG1089</a> (as <a href="http://lists.isocpp.org/core/2016/10/0998.php">reinterpreted</a> after <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1111">CWG1111</a>) is resolved by performing unqualified lookup for the first component of a <em>nested-name-specifier</em> in a class member access when a dependent type prevents finding anything. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1478">CWG1478</a> is resolved per <a href="http://lists.isocpp.org/core/2019/05/6192.php">my interpretation</a> as independently suggested by Richard in <a href="http://lists.isocpp.org/core/2019/05/6247.php">“Implementation status of core issue 96”</a>.</p>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2070">CWG2070</a> is resolved by specifying that a dependent <em>using-declarator</em> is considered to name a constructor if and only if it ends with <code>B::B</code>. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#852">CWG852</a> is resolved by explicitly mentioning <em>using-declaration</em>⁠s in class templates (and making it diagnosable in most cases to refer to a class that is definitely not a base).</p>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1545">CWG1545</a> is resolved by interpreting entire friend declarations upon instantiation of an enclosing template.</p>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2213">CWG2213</a> is resolved by allowing an <em>elaborated-type-specifier</em> to contain a <em>simple-template-id</em> without <code>friend</code>.</p>
<h1 id="wording">Wording</h1>
<p>Relative to N4830. <!-- TODO: include (some) removed paragraphs --></p>
<h2 id="intro.defs">[intro.defs]</h2>
<h3 id="defns.signature">[defns.signature]</h3>
<p>Change the definition (leaving the note):</p>
<blockquote>
<p><strong>signature</strong><br />〈function〉 name, parameter type list ([dcl.fct]), enclosing namespace<s> (if any)</s>, and trailing <em>requires-clause</em> ([dcl.decl]) (if any)</p>
</blockquote>
<h3 id="defns.signature.templ">[defns.signature.templ]</h3>
<p>Change:</p>
<blockquote>
<p><strong>signature</strong><br />〈function template〉 name, parameter type list ([dcl.fct]), enclosing namespace<s> (if any)</s>, return type, <em>template-head</em>, and trailing <em>requires-clause</em> ([dcl.decl]) (if any)</p>
</blockquote>
<h2 id="lex.ext">[lex.ext]</h2>
<p>Change paragraph 2:</p>
<blockquote>
<p>A <em>user-defined-literal</em> is treated as a call to a literal operator or literal operator template ([over.literal]). To determine the form of this call for a given <em>user-defined-literal</em> <em>L</em> with <em>ud-suffix</em> <em>X</em>, <u>first let <em>S</em> be the declarations found by unqualified lookup for </u>the <em>literal-operator-id</em> whose literal suffix identifier is <em>X</em><s> is looked up in the context of <em>L</em> using the rules for unqualified name lookup</s> ([basic.lookup.unqual]). <s>Let <em>S</em> be the set of declarations found by this lookup.</s> <em>S</em> shall not be empty.</p>
</blockquote>
<h2 id="basic">[basic]</h2>
<p>Change paragraph 5:</p>
<blockquote>
<p>A <em>name</em> is a use of an <em>identifier</em> ([lex.name]), <em>operator-function-id</em> ([over.oper]), <em>literal-operator-id</em> ([over.literal]), <u>or </u><em>conversion-function-id</em> ([class.conv.fct])<s>, or <em>template-id</em> ([temp.names])</s> that denotes an entity<s> or label ([stmt.goto], [stmt.label])</s>.</p>
</blockquote>
<p>Change paragraph 6:</p>
<blockquote>
<p>Every name<s> that denotes an entity</s> is introduced by a <em>declaration</em>. <s>Every name that denotes a label is introduced either by a <code>goto</code> statement ([stmt.goto]) or a <em>labeled-statement</em> ([stmt.label]).</s></p>
</blockquote>
<p>Remove bullet (9.4).</p>
<h3 id="basic.def.odr">[basic.def.odr]</h3>
<p>Change paragraph 4:</p>
<blockquote>
<p><u>A variable is named by an expression if the expression is an <em>id-expression</em> that denotes it.</u> A variable <code>x</code> <s>whose </s>name<u>d</u> <s>appears as</s><u>by</u> a potentially-evaluated expression <code>e</code> […]</p>
</blockquote>
<h3 id="basic.scope">[basic.scope]</h3>
<h4 id="basic.scope.declarative">[basic.scope.declarative]</h4>
<p>Remove subclause, referring the old stable name to [basic.scope.scope] (added below). Update the 2 surviving cross references (in [basic.def.odr]/9) to refer to [basic.scope.scope]. Replace the 9 surviving mentions of “declarative region” (in [basic.def.odr]/9, [expr.prim.id.unqual]/2, [expr.prim.lambda.capture]/7.3, and [namespace.def]/2) with “scope”.</p>
<h4 id="general-basic.scope.scope">General [basic.scope.scope]</h4>
<p>Add subclause to front of [basic.scope]:</p>
<blockquote>
<p>The declarations in a program appear in a number of <em>scopes</em> that are in general discontiguous. The <em>global scope</em> contains the entire program; every other scope is introduced by a declaration or statement (as described in the following subclauses of [basic.scope]) appearing in another scope which thereby contains the scope introduced. An <em>enclosing</em> scope at a program point is any scope that contains it. The smallest scope that contains a scope or program point is said to be its (singular) enclosing scope. A scope <em>intervenes</em> between a program point <em>P</em> and a scope <em>S</em> if it is or contains <em>S</em> but does not contain <em>P</em>.</p>
</blockquote>
<blockquote>
<p>Every declaration and entity <em>belongs</em> to a single scope. A declaration belongs to its enclosing scope. An entity belongs to the <em>target</em> scope of the declaration that introduces it. Unless otherwise specified:</p>
<ol style="list-style-type: decimal">
<li>A declaration’s target scope is the scope to which it belongs, and</li>
<li>Any names introduced by a declaration are <em>bound</em> to it in its target scope.</li>
</ol>
<p>A scope that is or contains the scope to which an entity belongs is an enclosing scope for that entity.</p>
</blockquote>
<blockquote>
<p>For the purpose of introducing entities and names, each</p>
<ol style="list-style-type: decimal">
<li><em>init-declarator</em> ([dcl.decl]),</li>
<li><em>identifier</em> in a structured binding declaration ([dcl.struct.bind]),</li>
<li><em>condition</em> with a <em>declarator</em> ([stmt.stmt]),</li>
<li><em>member-declarator</em> ([class.mem]),</li>
<li><em>using-declarator</em> ([namespace.udecl]),</li>
<li><em>parameter-declaration</em> ([dcl.fct]),</li>
<li><em>alias-declaration</em> ([dcl.typedef]),</li>
<li><em>concept-definition</em> ([temp.concept]),</li>
<li><em>type-parameter</em> ([temp.param]),</li>
<li><em>elaborated-type-specifier</em> that introduces a name ([dcl.type.elab]),</li>
<li><em>class-specifier</em> or <em>enum-specifier</em> with a name ([class], [dcl.enum]),</li>
<li><em>opaque-enum-declaration</em>,</li>
<li><em>enumerator-definition</em>, and</li>
<li>implicit declaration of an injected-class-name ([class])</li>
</ol>
<p>is considered to be a declaration. [<em>Note</em>: The interpretation of a <em>for-range-declaration</em> produces one or more of the above ([stmt.ranged]). — <em>end note</em>]</p>
</blockquote>
<blockquote>
<p>A name <em>denotes</em> an entity if it is introduced by a declaration of that entity or is a <em>typedef-name</em> introduced by a declaration specifying that entity. <!-- FIXME: "denote" is first used in [basic]/4 --></p>
</blockquote>
<blockquote>
<p>Two declarations <em>conflict</em> if the same name denotes distinct entities via each and</p>
<ol style="list-style-type: decimal">
<li>either declaration declares a <em>typedef-name</em>, or</li>
<li>both entities are types, or</li>
<li>neither entity is a type and either is not a function or function template, or</li>
<li>neither entity is a variable, non-static data member, enumerator, function, or function template, or</li>
<li>both entities are functions, or both are function templates, and they cannot be overloaded ([over.load]<!-- TODO: move [over.load]? -->).</li>
</ol>
<p>A declaration shall not conflict with another with the same target scope.<!-- TODO: NDR across TUs, or does [basic.link] cover that? --> [<em>Note</em>: Declarations might conflict even if neither binds a name. [<em>Example</em>:</p>
<pre class="sourceCode cpp"><code class="sourceCode cpp"><span class="kw">struct</span> A {
  <span class="kw">friend</span> <span class="dt">short</span> f();  <span class="co">// #1</span>
};
<span class="kw">struct</span> B {
  <span class="kw">friend</span> <span class="dt">float</span> f();  <span class="co">// error: conflicts with #1</span>
};</code></pre>
<p>— <em>end example</em>] — <em>end note</em>] In general, a name can otherwise be bound to multiple declarations in a scope.</p>
</blockquote>
<blockquote>
<p>When instantiating a templated entity ([temp]), any scope <em>S</em> associated with any part of the template definition is considered to be associated with the instantiated entity and to contain the instantiations of any declarations that belong to <em>S</em>.</p>
</blockquote>
<h4 id="basic.scope.pdecl">[basic.scope.pdecl]</h4>
<p>Change each paragraph 1–12: <!-- No > here; these are paragraph numbers. --></p>
<ol style="list-style-type: decimal">
<li><p>The <s><em>point of declaration</em></s><u><em>locus</em></u> for a <s>name</s><u>declaration that is a declarator</u> is immediately after <s>its</s><u>the</u> complete declarator ([dcl.decl])<s> and before its initializer (if any), except as noted below</s>. [<em>Example</em>:</p>
[…] — <em>end example</em>]</li>
<li><p>[<em>Note</em>: A name from an outer scope remains visible up to the <s>point</s><u>locus</u> of <u>the </u>declaration<s> of the name</s> that hides it. [<em>Example</em>:</p>
[…] — <em>end example</em>] — <em>end note</em>]</li>
<li>The <s>point</s><u>locus</u> of<s> declaration for a class or class template first declared by</s> a <em>class-specifier</em> is immediately after the <em>identifier</em> or <em>simple-template-id</em> (if any) in its <em>class-head</em> ([class]). The <s>point</s><u>locus</u> of <s>declaration for an enumeration</s><u>an <em>enum-specifier</em> or <em>opaque-enum-declaration</em></u> is immediately after the <em>identifier</em> (if any) in <s>either its <em>enum-specifier</em> ([dcl.enum]) or its first <em>opaque-enum-declaration</em></s><u>it</u> ([dcl.enum])<s>, whichever comes first</s>. The <s>point</s><u>locus</u> of <s>declaration of an alias or alias template</s><u>an <em>alias-declaration</em> is</u> immediately <s>follows the <em>defining-type-id</em> to which the alias refers</s><u>after it</u>.</li>
<li>The <s>point of declaration</s><u>locus</u> of a <em>using-declarator</em> that does not name a constructor is immediately after the <em>using-declarator</em> ([namespace.udecl]).</li>
<li><p>The <s>point of declaration for an enumerator</s><u>locus of an <em>enumerator-definition</em></u> is immediately after it<s>s enumerator-definition</s>. [<em>Example</em>:</p>
[…] — <em>end example</em>]</li>
<li><u>[<em>Note</em>: </u>After the <s>point of </s>declaration of a class member, the member name can be <s>looked up</s><u>found</u> in the scope of its class<s>. [<em>Note</em>: This is true</s> even if the class is an incomplete class. […] — <em>end note</em>]</li>
<li><s>[…]</s><u>The locus of an <em>elaborated-type-specifier</em> that is a declaration ([dcl.type.elab]) is immediately after it.</u></li>
<li>The <s>point of declaration for</s><u>locus of</u> an injected-class-name<u> declaration</u> ([class]) is immediately following the opening brace of the class definition.</li>
<li>The <s>point</s><u>locus</u> of<u> the implicit</u> declaration <s>for</s><u>of</u> a function-local predefined variable ([dcl.fct.def.general]) is immediately before the <em>function-body</em> of <s>a</s><u>its</u> function<u>’s</u> definition.</li>
<li>The <s>point</s><u>locus</u> of<u> the</u> declaration of a structured binding ([dcl.struct.bind]) is immediately after the <em>identifier-list</em> of the structured binding declaration.</li>
<li>The <s>point of declaration for the variable or the structured bindings declared in the</s><u>locus of a</u> for-range-declaration of a range-based for statement ([stmt.ranged]) is immediately after the <em>for-range-initializer</em>.</li>
<li><p>The <s>point of declaration for a template parameter</s><u>locus of a <em>template-parameter</em></u> is immediately after it<s>s complete <em>template-parameter</em></s>. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p></li>
</ol>
<p>Insert before paragraph 13:</p>
<blockquote>
<p>The locus of a <em>concept-definition</em> is immediately after its <em>concept-name</em> ([temp.concept]). [<em>Note</em>: The <em>constraint-expression</em> cannot use the <em>concept-name</em>. — <em>end note</em>]</p>
</blockquote>
<p>[<em>Drafting note</em>: There is no normative wording yet corresponding to this note. — <em>end drafting note</em>]</p>
<p>Change paragraph 13:</p>
<blockquote>
<p>[<em>Note</em>: Friend declarations <s>refer to</s><u>may introduce</u> functions or classes that <s>are members of</s><u>belong to</u> the nearest enclosing namespace<u> or block scope</u>, but they do not <s>introduce new</s><u>bind</u> names <s>into that namespace</s><u>anywhere</u> ([<s>namespace.memdef</s><u>class.friend</u>]). Function declarations at block scope and variable declarations with the <code>extern</code> specifier at block scope <s>refer to declarations that are members of an</s><u>declare entities that belong to the nearest</u> enclosing namespace, but they do not <s>introduce new</s><u>bind</u> names <s>into that scope</s><u>in it</u>. — <em>end note</em>]</p>
</blockquote>
<h4 id="basic.scope.block">[basic.scope.block]</h4>
<p>Replace contents:</p>
<blockquote>
<p>A <em>scoped statement</em> is a <em>compound-statement</em> of a <em>function-try-block</em> or either substatement of an <code>if</code> statement with an <code>else</code> part.</p>
</blockquote>
<blockquote>
<p>For each selection or iteration statement ([stmt.select], [stmt.iter]), <em>handler</em> ([except]), scoped statement, or compound statement ([stmt.block]) that is not</p>
<ol style="list-style-type: decimal">
<li>the <em>compound-statement</em> of a <em>lambda-expression</em> with a <em>lambda-declarator</em>, of a <em>handler</em>, or of a <em>function-body</em>, or</li>
<li>a unique substatement of a selection or iteration statement,</li>
</ol>
<p>there is a <em>block scope</em> that includes that statement or handler. [<em>Note</em>: A scoped statement that is also a block has only one scope. — <em>end note</em>] A variable that belongs to a block scope is a <em>local variable</em>.</p>
</blockquote>
<p>Move the example from [stmt.for]/3 to here.</p>
<blockquote>
<p>A declaration whose target scope is the block scope of a scoped statement shall not conflict with a declaration whose target scope is the enclosing scope.</p>
</blockquote>
<p>Move the example from [stmt.stmt]/5 to the end of this subclause.</p>
<h4 id="basic.scope.param">[basic.scope.param]</h4>
<p>Replace contents:</p>
<blockquote>
<p>For each <em>parameter-declaration-clause</em> <em>P</em> there is a <em>function parameter scope</em> that includes <em>P</em>. [<em>Note</em>: A function parameter cannot be used for its value within the <em>parameter-declaration-clause</em> ([dcl.fct.default]). — <em>end note</em>] If <em>P</em> is associated with a <em>declarator</em>, its scope extends to the end of that function declarator, or to the end of the <em>function-body</em> if the <em>declarator</em> is associated with a <em>function-definition</em>. [<em>Note</em>: A member function’s parameter scope is nested within its class’s scope. The handlers for a <em>function-try-block</em> are part of the <em>function-body</em>. — <em>end note</em>] If <em>P</em> is associated with a <em>lambda-declarator</em>, its scope extends to the end of the <em>compound-statement</em> in the <em>lambda-expression</em>. If <em>P</em> is associated with a <em>requirement-parameter-list</em>, its scope extends to the end of the <em>requirement-body</em> of the <em>requires-expression</em>. If <em>P</em> is associated with a <em>deduction-guide</em>, its scope extends to the end of the <em>deduction-guide</em>.</p>
</blockquote>
<blockquote>
<p>A declaration whose target scope is the block scope of a <em>handler</em> in a <em>function-try-block</em> shall not conflict with a declaration whose target scope is the enclosing (function parameter) scope.</p>
</blockquote>
<h4 id="basic.funscope">[basic.funscope]</h4>
<p>Remove subclause, referring the stable name (which has no cross references) to [stmt.label].</p>
<h4 id="basic.scope.namespace">[basic.scope.namespace]</h4>
<p>Replace contents:</p>
<blockquote>
<p>For each namespace <em>N</em> there is a <em>namespace scope</em> that includes the <em>namespace-body</em> for every <em>namespace-definition</em> for <em>N</em>. The scope also includes the portion of any redeclaration or specialization of an entity enclosed by it after the <em>declarator-id</em>, <em>class-head-name</em>, or <em>enum-head-name</em> that names the entity. The global scope is the namespace scope of the global namespace ([basic.namespace]).</p>
</blockquote>
<h4 id="basic.scope.class">[basic.scope.class]</h4>
<p>Replace contents:</p>
<blockquote>
<p>For each class or class template <em>C</em> there is a <em>class scope</em> that includes the <em>class-specifier</em> for <em>C</em>. The scope also includes the portion of any redeclaration or specialization of an entity enclosed by it after the <em>declarator-id</em>, <em>class-head-name</em>, or <em>enum-head-name</em> that names the entity. [<em>Note</em>: Lookup from a program point before the <em>class-specifier</em> of a class will find no bindings in its scope. — <em>end note</em>]</p>
</blockquote>
<h4 id="basic.scope.enum">[basic.scope.enum]</h4>
<p>Replace contents:</p>
<blockquote>
<p>For each enumeration <em>E</em> there is an <em>enumeration scope</em> that includes the <em>enum-specifier</em> for <em>E</em>. [<em>Note</em>: The names of unscoped enumerators are also bound in the enclosing scope ([dcl.enum]). — ⁠<em>end note</em>]</p>
</blockquote>
<h4 id="basic.scope.temp">[basic.scope.temp]</h4>
<p>Replace contents:</p>
<blockquote>
<p>For each template <em>template-parameter</em> there is a <em>template parameter scope</em> that includes the <em>template-head</em> of the <em>template-parameter</em>.</p>
</blockquote>
<blockquote>
<p>For each <em>template-declaration</em> there is a template parameter scope that includes it. Any declaration outside the <em>template-parameter-list</em> that would belong to the template parameter scope instead belongs to its enclosing scope.<!-- remote --> [<em>Note</em>: Therefore, only template parameters belong to a template parameter scope. — <em>end note</em>]</p>
</blockquote>
<h4 id="basic.scope.hiding">[basic.scope.hiding]</h4>
<p>Remove subclause, referring the stable name to [basic.lookup].</p>
<h3 id="basic.lookup">[basic.lookup]</h3>
<p>Change paragraph 1:</p>
<blockquote>
<p>[…] Name lookup associates the use of a name with a set of declarations ([basic.def]) of that name. <u>Unless otherwise specified, the program is ill-formed if no declarations are found.</u> The declarations found by name lookup <s>shall </s>either</p>
<ol style="list-style-type: decimal">
<li>all denote the same entity<u>,</u> or</li>
<li><s>shall </s>all denote functions or function templates<s>;</s><u>,</u> in <s>the latter</s><u>which</u> case<s>,</s> the<s> declarations</s><u>y</u> are said to form a<s> set of</s><u>n</u> overload<s>ed functions</s><u> set</u> ([over.load])<s>.</s><u>, or</u></li>
<li><u>are <em>ambiguous</em>, and the program is ill-formed</u>.</li>
</ol>
<p>Overload resolution ([over.match]) takes place after name lookup has succeeded. The access rules ([class.access]) are considered only once name lookup and function overload resolution (if applicable) have succeeded. Only after name lookup, function overload resolution (if applicable) and access checking have succeeded are the semantic properties introduced by the name’s declaration and its reachable ([module.reach]) redeclarations used further in expression processing ([expr]). <!-- TODO: add something about universal overload resolution?  note that pseudo-destructors would violate [over]/2 --></p>
</blockquote>
<p>Insert before paragraph 2:</p>
<blockquote>
<p>A program point <em>P</em> <em>follows</em> any declaration in the same translation unit whose locus ([basic.scope.pdecl]) is before <em>P</em>. [<em>Note</em>: The declaration might appear in a scope that does not contain <em>P</em>. — <em>end note</em>]</p>
</blockquote>
<blockquote>
<p>A declaration <em>X</em> <em>precedes</em> a program point <em>P</em> in a translation unit <em>L</em> if <em>P</em> follows <em>X</em>, or else <em>X</em> appears in a translation unit <em>D</em> and</p>
<ol style="list-style-type: decimal">
<li><em>P</em> follows a <em>module-import-declaration</em> or <em>module-declaration</em> that imports <em>D</em> (directly or indirectly), and</li>
<li><em>X</em> appears after the <em>module-declaration</em> in <em>D</em> (if any) and before the <em>private-module-fragment</em> in <em>D</em> (if any), and</li>
<li>either <em>X</em> is exported or <em>D</em> and <em>L</em> are part of the same module, and</li>
<li><em>X</em> does not declare a name with internal linkage. <u>[<em>Note</em>: Names declared by a <em>using-declaration</em> have no linkage. — <em>end note</em>]</u></li>
</ol>
</blockquote>
<p>Move the note (and example) from [basic.scope.namespace]/2 to the end of this paragraph.</p>
<p>Remove paragraphs 2 and 3.</p>
<p>Append paragraphs:</p>
<blockquote>
<p>A <em>single search</em> in a scope <em>S</em> for a name <em>N</em> from a program point <em>P</em> finds the declarations in <em>S</em> that precede <em>P</em> and to which any name that is the same as <em>N</em> ([basic]) is bound. If any such declaration is a <em>using-declarator</em> that is not dependent ([temp.dep.type]), it is replaced by the declarations named by the <em>using-declarator</em> ([namespace.udecl]). If the containing <em>using-declaration</em> is a <em>member-declaration</em>, the replacement declarations are considered to have the access of the <em>using-declaration</em>.<!-- remote --></p>
</blockquote>
<blockquote>
<p>In certain contexts, only certain kinds of declarations are included. After any such restriction, any declarations of classes or enumerations are discarded if any other declarations are found. [<em>Note</em>: A type (but not a <em>typedef-name</em> or template) is therefore hidden by any other entity in its scope. — <em>end note</em>] However, if a lookup is <em>type-only</em>, only declarations of types and templates whose specializations are types are considered; furthermore, if a <code>typedef</code> declarator and a declaration of the type to which it refers are found, the <code>typedef</code> declarator is discarded instead of the type declaration.</p>
</blockquote>
<blockquote>
<p>If <em>N</em> is a <em>conversion-function-id</em>, conversion function templates that belong to <em>S</em> are considered. For each such template, if template argument deduction succeeds ([temp.deduct.conv]), an invented declaration of the resulting specialization is included in the result.</p>
</blockquote>
<h4 id="class.member.lookup">[class.member.lookup]</h4>
<p>Move to front of [basic.lookup], editing as follows:</p>
<p>Remove paragraph 1.</p>
<p>Change paragraph 2:</p>
<blockquote>
<p><s>T</s><u>A <em>search</em> in a scope <em>C</em> for a name <em>N</em> from a program point <em>P</em> is a single search in <em>C</em> for <em>N</em> from <em>P</em> unless <em>C</em> is a class or class template, in which case t</u>he following steps define the result of <s>a member name <code>f</code> in a class scope <code>C</code></s><u>the search</u>. <u>[<em>Note</em>: The result differs only if the single search would find nothing. — <em>end note</em>]</u></p>
</blockquote>
<p>Replace <code>f</code> with <em>N</em> and <code>C</code> with <em>C</em> in the following paragraphs.</p>
<p>Change paragraph 3:</p>
<blockquote>
<p>The <em>lookup set</em> for <s><code>f</code></s><u><em>N</em></u> in <s><code>C</code></s><u><em>C</em></u>, called <em>S</em>(<em><s>f</s><u>N</u></em>,<em>C</em>), consists of two component sets: the <em>declaration set</em>, a set of members named <s><code>f</code></s><u><em>N</em></u>; and the <em>subobject set</em>, a set of subobjects where declarations of these members<s> (possibly including <em>using-declaration</em>⁠s)</s> were found<u> (possibly via <em>using-declaration</em>⁠s)</u>. In the declaration set, <s><em>using-declaration</em>⁠s are replaced by the set of designated members that are not hidden or overridden by members of the derived class ([namespace.udecl]), and </s>type declarations (including injected-class-names) are replaced by the types they designate. <em>S</em>(<em><s>f</s><u>N</u></em>,<em>C</em>) is calculated as follows:</p>
</blockquote>
<p>Change paragraph 4:</p>
<blockquote>
<p><s>If <code>C</code> contains a declaration of the name <code>f</code>, the declaration set contains every declaration of <code>f</code> declared in <code>C</code> that satisfies the requirements of the language construct in which the lookup occurs.</s> <u>The declaration set is the result of a single search in <em>C</em> for <em>N</em> from immediately after the <em>class-specifier</em> of <em>C</em> if <em>P</em> is in a complete-class context of <em>C</em> or from <em>P</em> otherwise.</u> [<em>Note</em>: […] — <em>end note</em>][…]</p>
</blockquote>
<p>[<em>Drafting note</em>: The plan for CWG2335 is to describe forbidden dependency cycles among the complete-class contexts of a class. — <em>end drafting note</em>]</p>
<p>Change paragraph 5:</p>
<blockquote>
<p>[…] <s>If <code>C</code> has base classes, c</s><u>C</u>alculate the lookup set for <s><code>f</code></s><u><em>N</em></u> in each direct <u>non-dependent ([temp.dep.type]) </u>base class subobject <em>B<sub>i</sub></em>, and merge each such lookup set <em>S</em>(<em><s>f</s><u>N</u></em>,<em>B<sub>i</sub></em>) in turn into <em>S</em>(<em><s>f</s><u>N</u></em>,<em>C</em>). <u>[<em>Note</em>: If <em>C</em> is incomplete, only base classes whose <em>base-specifier</em> appears before <em>P</em> are considered. If <em>C</em> is an instantiated class, its base classes are not dependent. — <em>end note</em>]</u></p>
</blockquote>
<p>Change paragraph 7:</p>
<blockquote>
<p>The result of <s>name lookup for <code>f</code> in <code>C</code></s><u>the search</u> is the declaration set of <em>S</em>(<em><s>f</s><u>N</u></em>,<em>C</em>). If it is an invalid set, the program is ill-formed. <u>If the use of <em>N</em> is followed by a <code>&lt;</code> that is not interpreted as part of a template argument list ([temp.names]) and the result contains any declaration of a template, the program is ill-formed, no diagnostic required. If it differs from the result of a search in <em>C</em> for <em>N</em> from immediately after the <em>class-specifier</em> of <em>C</em>, the program is ill-formed, no diagnostic required.</u></p>
</blockquote>
<p>Remove paragraph 8.</p>
<h4 id="basic.lookup.unqual">[basic.lookup.unqual]</h4>
<p>Replace contents (including the existing paragraph 16 at the end):</p>
<blockquote>
<p>A <em>using-directive</em> is active in a scope <em>S</em> at a program point <em>P</em> if <em>P</em> appears later in the same translation unit and it belongs to <em>S</em> or to the scope of a namespace nominated by a <em>using-directive</em> that is active in <em>S</em> at <em>P</em>.</p>
</blockquote>
<blockquote>
<p>An <em>unqualified search</em> in a scope <em>S</em> from a program point <em>P</em> includes the results of searches from <em>P</em> in</p>
<ol style="list-style-type: decimal">
<li><em>S</em>, and</li>
<li>for any scope <em>U</em> that contains <em>P</em> and is or is contained by <em>S</em>, each namespace contained by <em>S</em> that is nominated by a <em>using-directive</em> that is active in <em>U</em> at <em>P</em>.</li>
</ol>
<p>If no declarations are found, the unqualified search also includes an unqualified search in the enclosing scope of <em>S</em>, if any, from <em>P</em>. [<em>Note</em>: When a class scope is searched, the scopes of its base classes are also searched ([class.member.lookup]). If it inherits from a single base, it is as if the scope of the base immediately contains the scope of the derived class. — <em>end note</em>]</p>
</blockquote>
<blockquote>
<p><em>Unqualified name lookup</em> from a program point performs an unqualified search in its enclosing scope.</p>
</blockquote>
<blockquote>
<p>An <em>unqualified name</em> is a name that does not follow a <em>nested-name-specifier</em> or the <code>.</code> or <code>-&gt;</code> in a class member access expression ([expr.ref]), possibly after a <code>template</code> keyword or <code>~</code>. Unless otherwise specified, such a name undergoes unqualified name lookup from the point where it appears.</p>
</blockquote>
<blockquote>
<p>An unqualified name that appears in a <em>conversion-type-id</em> is looked up in the same fashion as the <em>conversion-function-id</em> in which it appears. If that lookup finds nothing, it undergoes unqualified name lookup; in each case, only names that denote types or templates whose specializations are types are considered.<!-- remote --></p>
</blockquote>
<blockquote>
<p>In a friend declaration, lookup for an unqualified name that appears in a <em>declarator</em> after a <em>declarator-id</em> with a <em>nested-name-specifier</em> that names a class, class template, or namespace <em>S</em> performs an unqualified search in <em>S</em>.<!-- non-nested --> If that lookup finds nothing, it undergoes unqualified name lookup.</p>
</blockquote>
<blockquote>
<p>[<em>Note</em>: The rules for name lookup in template definitions are described in [temp.res]. — <em>end note</em>]</p>
</blockquote>
<h4 id="basic.lookup.argdep">[basic.lookup.argdep]</h4>
<p>Change paragraph 1:</p>
<blockquote>
<p>When the <em>postfix-expression</em> in a function call ([expr.call]) is an <em>unqualified-id</em>, <u>and</u><s>other namespaces not considered during the usual</s> unqualified lookup ([basic.lookup.unqual]) <s>may be searched, and in those namespaces, namespace-scope friend function or function template declarations ([class.friend]) not otherwise visible may be found. These modifications to the search</s><u>for the name in the <em>unqualified-id</em> does not find any</u></p>
<ol style="list-style-type: decimal">
<li><u>declaration of a class member, or</u></li>
<li><u>function declaration belonging to a block scope, or</u></li>
<li><u>declaration not of a function or function template</u></li>
</ol>
<p><u>then lookup for the name also includes the result of <em>argument-dependent lookup</em> in a set of <em>associated namespaces</em> that</u> depend<u>s</u> on the types of the arguments (and for template template arguments, the namespace of the template argument)<u>, as specified below</u>. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Move the note from [basic.lookup.unqual]/3 here, inserting it before paragraph 2.</p>
<p>Change paragraph 2:</p>
<blockquote>
<p>For each argument type <code>T</code> in the function call, there is <s>a set of zero or more <em>associated namespaces</em> and </s>a set of zero or more <em>associated entities</em><s> (other than namespaces)</s> to be considered. The set<s>s</s> of <s>namespaces and </s>entities <s>are</s><u>is</u> determined entirely by the types of the function arguments (and <s>the namespace of </s>any template template argument<u>s</u>). Typedef names and <em>using-declaration</em>⁠s used to specify the types do not contribute to this set. The set<s>s</s> of <s>namespaces and </s>entities <s>are</s><u>is</u> determined in the following way:</p>
<ol style="list-style-type: decimal">
<li>If <code>T</code> is a fundamental type, its associated set<s>s</s> of <s>namespaces and </s>entities <s>are both</s><u>is</u> empty.</li>
<li>If <code>T</code> is a class type (including unions), its associated entities are: the class itself; the class of which it is a member, if any; and its direct and indirect base classes. <s>Its associated namespaces are the innermost enclosing namespaces of its associated entities.</s> Furthermore, if <code>T</code> is a class template specialization, its associated <s>namespaces and </s>entities also include: the <s>namespaces and </s>entities associated with the types of the template arguments provided for template type parameters<s> (excluding template template parameters)</s>; the templates used as template template arguments;<s> the namespaces of which any template template arguments are members;</s> and the classes of which any member templates used as template template arguments are members. [<em>Note</em>: Non-type template arguments do not contribute to the set of associated <s>namespaces</s><u>entities</u>. — <em>end note</em>]</li>
<li>If <code>T</code> is an enumeration type, <s>its associated namespace is the innermost enclosing namespace of its declaration, and </s>its associated entities are <code>T</code> and, if it is a class member, the member’s class.</li>
<li>If <code>T</code> is a pointer to <code>U</code> or an array of <code>U</code>, its associated <s>namespaces and </s>entities are those associated with <code>U</code>.</li>
<li>If <code>T</code> is a function type, its associated <s>namespaces and </s>entities are those associated with the function parameter types and those associated with the return type.</li>
<li>If <code>T</code> is a pointer to a member function of a class <code>X</code>, its associated <s>namespaces and </s>entities are those associated with the function parameter types and return type, together with those associated with <code>X</code>.</li>
<li>If <code>T</code> is a pointer to a data member of class <code>X</code>, its associated <s>namespaces and </s>entities are those associated with the member type together with those associated with <code>X</code>.</li>
</ol>
<p><s>If an associated namespace is an inline namespace ([namespace.def]), its enclosing namespace is also included in the set. If an associated namespace directly contains inline namespaces, those inline namespaces are also included in the set.</s> In addition, if the argument is <s>the name or address of </s>a set of overloaded functions and/or function templates<u> or the address of such a set</u>, its associated entities<s> and namespaces</s> are the union of those associated with each of the members of the set, i.e., the entities<s> and namespaces</s> associated with its parameter types and return type. Additionally, if the aforementioned set of overloaded functions is named with a <em>template-id</em>, its associated entities<s> and namespaces</s> also include <s>those of its type <em>template-argument</em>⁠s and </s>its template <em>template-argument</em>⁠s<u> and those associated with its type <em>template-argument</em>⁠s</u>.</p>
</blockquote>
<p>Change paragraph 3 and move it to the end of the subclause:</p>
<blockquote>
<p><s>Let <em>X</em> be the lookup set produced by unqualified lookup ([basic.lookup.unqual]) and let <em>Y</em> be the lookup set produced by argument dependent lookup (defined as follows). If <em>X</em> contains</s></p>
<ol style="list-style-type: decimal">
<li><s>a declaration of a class member, or</s></li>
<li><s>a block-scope function declaration that is not a <em>using-declaration</em>, or</s></li>
<li><s>a declaration that is neither a function nor a function template</s></li>
</ol>
<p><s>then <em>Y</em> is empty. Otherwise <em>Y</em> is the set of declarations found in the namespaces associated with the argument types as described below. The set of declarations found by the lookup of the name is the union of <em>X</em> and <em>Y</em>.</s> [<em>Note</em>: The <u>associated </u>namespaces<s> and entities associated with the argument types</s> can include namespaces<s> and entities</s> already considered by <s>the </s>ordinary unqualified lookup. — <em>end note</em>] [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 4:</p>
<blockquote>
<p><s>When considering an</s><u>The associated namespaces for a call are the innermost enclosing non-inline namespaces for its associated entities. Argument-dependent lookup finds the results of qualified name lookup in each</u> associated namespace<s> <code>N</code></s>, <s>the lookup is the same as the lookup performed when <code>N</code> is used as a qualifier</s> ([namespace.qual]) except that:<!-- remote --></p>
<ol style="list-style-type: decimal">
<li>A<s>ny</s><u>ll</u> <em>using-directive</em>⁠s<s> in <code>N</code></s> are ignored.</li>
<li><s>All names except those</s><u>Only declarations</u> of <s>(possibly overloaded) </s>functions and function templates are <s>ignored</s><u>considered</u>.</li>
<li>Any <s>namespace-scope</s><u>declaration of a</u> friend function<s>s</s> or friend function template<s>s</s> ([class.friend]) <s>declared </s>in <u>a </u>class<s>es</s> with <u>a </u>reachable definition<s>s</s> in the set of associated entities <s>are visible within their respective namespaces even if they are not visible during an ordinary lookup ([namespace.memdef])</s><u>is considered to precede the point of the lookup, and the name declared is considered to be bound to it in its target scope</u>.</li>
<li>Any declaration <code>D</code> <s>in <code>N</code> that is </s>in the interface of a named module <code>M</code> ([module.interface]) is <s>visible</s><u>considered to precede the point of the lookup <em>P</em></u> if <u>it does not appear in the translation unit containing <em>P</em> and </u>there is an associated entity attached to <code>M</code> with the same innermost enclosing non-inline namespace<u> scope</u> as <code>D</code>.</li>
</ol>
<p><s>5.</s> If the lookup is for a dependent name ([temp.dep], [temp.dep.candidate]), <s>any declaration <code>D</code> in <code>N</code> is visible if <code>D</code> would be visible to qualified name lookup ([namespace.qual]) at any</s><u>the above lookup is also performed from each</u> point in the instantiation context ([module.context]) of the lookup, <s>unless <code>D</code> is declared</s><u>additionally ignoring any declaration that appears</u> in another translation unit, <u>is </u>attached to the global module, and is either discarded ([module.global]) or has internal linkage.</p>
</blockquote>
<h4 id="basic.lookup.qual">[basic.lookup.qual]</h4>
<p>Change paragraph 1:</p>
<blockquote>
<p><s>The name of a class or namespace member or enumerator can be referred to after the <code>::</code> scope resolution operator ([expr.prim.id.qual]) applied to a <em>nested-name-specifier</em> that denotes its class, namespace, or enumeration.</s> <s>If</s><u>Lookup of an <em>identifier</em>, or the name in a <em>template-id</em>, followed by</u> a <code>::</code> scope resolution operator<s> in a <em>nested-name-specifier</em> is not preceded by a <em>decltype-specifier</em>, lookup of the name preceding that <code>::</code></s> considers only namespaces, types, and templates whose specializations are types.<!-- remote --> <u>[<em>Note</em>: An <em>identifier</em> followed by <code>&lt;</code> is not considered to be part of a <em>template-id</em> during a lookup to determine the interpretation of the <code>&lt;</code> ([temp.names]). — <em>end note</em>]</u> If <s>the name found does not</s><u>a name, <em>template-id</em>, or <em>decltype-specifier</em> is followed by a <code>::</code>, it shall</u> designate a namespace<s> or a</s><u>,</u> class, enumeration, or dependent type, <s>the program is ill-formed</s><u>and the <code>::</code> is never interpreted as a complete <em>nested-name-specifier</em></u>. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Insert before paragraph 2:</p>
<blockquote>
<p>A <em>member-qualified name</em> is an <em>unqualified-id</em>, or a <em>nested-name-specifier</em> of the form <em>type-name</em> <code>::</code> or <em>namespace-name</em> <code>::</code>, in the <em>id-expression</em> of a class member access expression ([expr.ref]). A <em>qualified name</em> is a member-qualified name, a <em>qualified-id</em>, a <em>using-declarator</em>, a <em>typename-specifier</em>, or a <em>nested-name-specifier</em>, <em>elaborated-type-specifier</em>, or <em>class-or-decltype</em> that contains a <em>nested-name-specifier</em> ([expr.prim.id.qual]). The <em>lookup context</em> of a member-qualified name is the type of its associated object expression (considered dependent if the object expression is type-dependent). The lookup context of any other qualified name is the type or namespace nominated by its <em>nested-name-specifier</em>. The <em>terminal name</em> of a qualified name is the <em>identifier</em> (including that of a <em>simple-template-id</em>) in it or the (initial) name in the <em>unqualified-id</em> that is or is in the qualified name. [<em>Note</em>: When parsing a class member access, the name following the <code>-&gt;</code> or <code>.</code> is a terminal name even though it is not yet known of which kind. — <em>end note</em>]</p>
</blockquote>
<blockquote>
<p><em>Qualified name lookup</em> in a class, namespace, or enumeration performs a search of the scope associated with it ([class.member.lookup]) except as specified below. Unless otherwise specified, a terminal name undergoes qualified name lookup in the lookup context of its qualified name from the point where it appears unless the lookup context either is dependent and is not the current instantiation ([temp.dep.type]) or is not a class or class template. If nothing is found by qualified lookup for the terminal name of a member-qualified name that is a <em>nested-name-specifier</em>, the terminal name undergoes unqualified lookup. [<em>Example</em>:</p>
<pre class="sourceCode cpp"><code class="sourceCode cpp"><span class="dt">int</span> f();
<span class="kw">struct</span> A {
  <span class="kw">template</span>&lt;<span class="dt">int</span>&gt; <span class="kw">using</span> B=A;
  <span class="dt">int</span> C;
  <span class="kw">template</span>&lt;<span class="dt">int</span>&gt; <span class="kw">using</span> D=<span class="dt">void</span>;
  <span class="kw">typedef</span> A E,T;
  <span class="dt">void</span> f();
};
<span class="kw">template</span>&lt;<span class="dt">int</span>&gt; <span class="kw">using</span> C=A;
<span class="kw">template</span>&lt;<span class="dt">int</span>&gt; <span class="kw">using</span> D=A;
<span class="kw">template</span>&lt;<span class="dt">int</span>&gt; <span class="kw">using</span> E=A;

<span class="kw">template</span>&lt;<span class="kw">class</span> T&gt;
<span class="dt">void</span> g(T *p) {
  p-&gt;<span class="kw">template</span> B&lt;<span class="dv">0</span>&gt;::f();     <span class="co">// error: B not found and not dependent</span>
  p-&gt;T::<span class="kw">template</span> B&lt;<span class="dv">0</span>&gt;::f();  <span class="co">// OK: T is the template parameter; A::B found in f&lt;A&gt;</span>
  p-&gt;T::T::f();              <span class="co">// OK: second T is A::T in f&lt;A&gt;</span>
  p-&gt;C&lt;<span class="dv">0</span>&gt;::f();              <span class="co">// OK: (p-&gt;C &lt; 0) &gt; ::f()</span>
  p-&gt;<span class="kw">template</span> D&lt;<span class="dv">0</span>&gt;::f();     <span class="co">// OK: ::D found in definition context</span>
}
<span class="kw">template</span> <span class="dt">void</span> g(A*);

<span class="dt">void</span> h(A a) {
  a.<span class="kw">template</span> C&lt;<span class="dv">0</span>&gt;::f();      <span class="co">// OK: non-type A::C ignored</span>
  a.<span class="kw">template</span> E&lt;<span class="dv">0</span>&gt;::f();      <span class="co">// error: E is A::E which is not a template</span>
}</code></pre>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Remove paragraphs 3 through 5.</p>
<p>Change paragraph 6:</p>
<blockquote>
<p><s>In a <em>qualified-id</em> of the form:</s></p>
<blockquote>
<p><s><em>nested-name-specifier</em><sub><em>opt</em></sub> <em>type-name</em> <code>::</code> <code>~</code> <em>type-name</em></s></p>
</blockquote>
<p><s>the second <em>type-name</em> is looked up in the same scope as the first.</s> <u>If the qualified name is or contains an <em>unqualified-id</em> that begins with <code>~</code> <em>identifier</em>:</u></p>
<ol style="list-style-type: decimal">
<li><u>If the qualified name is not a member-qualified name:</u>
<ol style="list-style-type: decimal">
<li><u>Its <em>nested-name-specifier</em> shall nominate a type.</u></li>
<li><u>If the <em>nested-name-specifier</em> is a qualified name, the <em>identifier</em> is looked up in the same fashion as its terminal name.</u></li>
</ol>
<u>[<em>Note</em>: Otherwise, the qualified name is looked up normally. — <em>end note</em>]</u></li>
<li><u>If lookup for the <em>identifier</em> finds nothing or finds it to be a <em>type-name</em> that does not refer to the lookup context (ignoring <em>cv</em>-qualification), it instead undergoes unqualified lookup.</u></li>
<li><u>Each lookup for the <em>identifier</em> considers only types (if the <em>identifier</em> is not followed by a <code>&lt;</code>) and templates whose specializations are types.</u></li>
<li><u>The <em>type-name</em> that is or contains the <em>identifier</em> shall ultimately refer to the lookup context (ignoring <em>cv</em>-qualification).</u></li>
</ol>
[<em>Example</em>:
<pre class="cpp">
struct C {
  typedef int I;<u>
  typedef float I2;</u>
};
typedef int I1, I2;
extern int* p;
extern int* q;
<u>void f() {
  </u>p->C::I::~I<u>2</u>();   <s>   </s>// <u>after finding C::</u>I<u>2</u><s> is</s><u>, unqualified</u> look<s>ed </s>up <s>in the scope of C</s><u>finds ::I2</u>
<u>  </u>q->I1::~I2();     <s>  </s>// I2 <s>is</s><u>undergoes unqualified</u> look<s>ed </s>up<s> in the scope of the postfix-expression</s><u>
}</u>

struct A {<u>
  typedef A AB;</u>
  ~A();
}<u> a</u>;
<s>typedef A AB;
</s>int main() {
  A<s>B</s>* p;
  p->A<s>B</s>::~AB();     <u> </u>// explicitly calls the destructor for A<u>
  p->decltype(a)::~AB(); // error: AB not found</u>
}
</pre>
<p>— <em>end example</em>] <s>[<em>Note</em>: [basic.lookup.classref] describes how name lookup proceeds after the <code>.</code> and <code>-&gt;</code> operators. — <em>end note</em>]</s></p>
</blockquote>
<h5 id="class.qual">[class.qual]</h5>
<p>Remove paragraph 1.</p>
<p>Change paragraph 2:</p>
<blockquote>
<p>In a lookup in which function names are not ignored<sup>[…]</sup> <s>and the</s><u>for a qualified name with a</u> <em>nested-name-specifier</em> <u>that </u>nominates a class <code>C</code>:</p>
<ol style="list-style-type: decimal">
<li>if the <s>name specified after the <em>nested-name-specifier</em>, when looked up in <code>C</code>, is</s><u>search finds</u> the injected-class-name of <code>C</code> ([class]), or</li>
<li>i<s>n</s><u>f the qualified name is</u> a <em>using-declarator</em><s> of a <em>using-declaration</em></s> ([namespace.udecl]) that is <s>a <em>member-declaration</em>, if the name specified after the <em>nested-name-specifier</em> is the same as the <em>identifier</em> or the <em>simple-template-id</em>’s <em>template-name</em> in the last component of the <em>nested-name-specifier</em></s><u>dependent and names a constructor</u>,</li>
</ol>
<p>the name is instead considered to name the constructor of class <code>C</code>. <s>[<em>Note</em>: For example, the constructor is not an acceptable lookup result in an <em>elaborated-type-specifier</em> so the constructor would not be used in place of the injected-class-name. — <em>end note</em>]</s> Such a constructor name shall be used only in the <em>declarator-id</em> of a declaration that names a constructor or in a <em>using-declaration</em>. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Remove paragraph 3.</p>
<h5 id="namespace.qual">[namespace.qual]</h5>
<p>Remove paragraphs 1 and 2.</p>
<p>Replace paragraph 3, retaining its example:</p>
<blockquote>
<p>Qualified name lookup in a namespace <em>N</em> additionally searches every element of the inline namespace set of <em>N</em> ([namespace.def]), ignoring unnamed namespaces defined in translation units that do not contain the point of the lookup ([namespace.unnamed]). If nothing is found, it includes the results of qualified name lookup in each namespace nominated by a <em>using-directive</em> that is followed by the point of the lookup and belongs to <em>N</em> or to a element of its inline namespace set. [<em>Note</em>: If a <em>using-directive</em> refers to a namespace that has already been considered, it does not affect the result. — <em>end note</em>] [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 6:</p>
<blockquote>
<p><s>During the lookup of a qualified namespace member name, if the lookup finds more than one declaration of the member, and if one declaration introduces a c</s><u>[<em>Note</em>: C</u>lass <s>name or</s><u>and</u> enumeration <s>name and the</s><u>declarations are not discarded because of</u> other declarations <s>introduce either the same variable, the same enumerator, or a set of functions, the non-type name hides the class or enumeration name if and only if the declarations are from the same namespace; otherwise (the declarations are from different namespaces), the program is ill-formed</s><u>found in other searches</u>.<u> — <em>end note</em>]</u> [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Remove paragraph 7.</p>
<h4 id="basic.lookup.elab">[basic.lookup.elab]</h4>
<p>Remove paragraphs 1 and 2.</p>
<p>Insert before paragraph 3:</p>
<blockquote>
<p>If the <em>class-key</em> or <code>enum</code> keyword in an <em>elaborated-type-specifier</em> is followed by an <em>identifier</em> that is not followed by <code>::</code>, lookup for the <em>identifier</em> is type-only. [<em>Note</em>: In general, the recognition of an <em>elaborated-type-specifier</em> depends on the following tokens. If the <em>identifier</em> is followed by <code>::</code>, see [basic.lookup.qual]. — <em>end note</em>]</p>
</blockquote>
<p>Change paragraph 3:</p>
<blockquote>
<p>If the <em>elaborated-type-specifier</em> has a <em>nested-name-specifier</em>, <s>qualified name </s>lookup <s>is performed, as described in [basic.lookup.qual], but ignoring any non-type names that have been declared</s><u>for the following <em>identifier</em> is type-only</u>. If the name lookup does not find a previously declared <em>type-name</em>, the <em>elaborated-type-specifier</em> is ill-formed.</p>
</blockquote>
<h4 id="basic.lookup.classref">[basic.lookup.classref]</h4>
<p>Remove subclause, referring the stable name and the cross reference in [expr.ref]/4 to [basic.lookup.qual].<!-- TODO: cross-references remain in [expr.await]/3.2, [stmt.ranged]/1.5, [dcl.fct.def.coroutine]/10, [dcl.struct.bind]/4 --></p>
<h3 id="basic.link">[basic.link]</h3>
<p>Change paragraph 5:</p>
<blockquote>
<p><s>A</s><u>The</u> name <s>having</s><u>of an entity that belongs to a</u> namespace scope ([basic.scope.namespace]) has internal linkage if it is the name of</p>
<p>[…]</p>
</blockquote>
<p>Change paragraph 8:</p>
<blockquote>
<s>The name of a function declared in block scope and the name of a variable declared by a block scope <code>extern</code> declaration have linkage. If such a declaration is attached to a named module, the program is ill-formed. If there is a visible declaration of an entity with linkage, ignoring entities declared outside the innermost enclosing namespace scope, such that the block scope declaration would be a (possibly ill-formed) redeclaration if the two declarations appeared in the same declarative region, the block scope declaration declares that same entity and receives the linkage of the previous declaration. If there is more than one such matching entity, the program is ill-formed. Otherwise, if no matching entity is found, the block scope entity receives external linkage. If, within a translation unit, the same entity is declared with both internal and external linkage, the program is ill-formed.</s> [<em>Example</em>:
<pre class="cpp">
static void f();
extern "C" void h();
static int i = 0;               // #1
void <s>g</s><u>q</u>() {
  extern void f();              // internal linkage<u>
  extern void g();              // ::g, external linkage</u>
  extern void h();              // C language linkage
  int i;                        // #2: i has no linkage
  {
    extern void f();            // internal linkage
    extern int i;               // #3: <s>ex</s><u>in</u>ternal linkage<s>, ill-formed</s>
  }
}
</pre>

<p><s>Without</s><u>Even though</u> the declaration at line #2<u> hides the declaration at line #1</u>, the declaration at line #3 <s>would link with the</s><u>still</u> <u>re</u>declar<s>ation</s><u>es</u> <s>at line </s>#1<s>. Because the declaration with</s><u> and receives</u> internal linkage<s> is hidden, however, #3 is given external linkage, making the program ill-formed</s>. — <em>end example</em>]</p>
</blockquote>
<p>Remove paragraph 9 (whose example is moved to [dcl.meaning]).</p>
<p>Change bullet (11.2):</p>
<blockquote>
<p>both names refer to <s>members of</s><u>entities that belong to</u> the same namespace or <s>to members, not by inheritance, of the same </s>class; and</p>
</blockquote>
<h2 id="expr">[expr]</h2>
<h3 id="expr.prim">[expr.prim]</h3>
<h4 id="expr.prim.this">[expr.prim.this]</h4>
<p>Insert before paragraph 2:</p>
<blockquote>
<p>The <em>current class</em> at a program point is the class associated with the smallest class scope containing that point. [<em>Note</em>: A <em>lambda-expression</em> does not contain any class scope. — <em>end note</em>]</p>
</blockquote>
<p>Change paragraph 2:</p>
<blockquote>
<p>If a declaration declares a member function or member function template of a class <code>X</code>, the expression <code>this</code> is a prvalue of type “pointer to <em>cv-qualifier-seq</em> <code>X</code>”<u> wherever <code>X</code> is the current class</u> between the optional <em>cv-qualifier-seq</em> and the end of the <em>function-definition</em>, <em>member-declarator</em>, or <em>declarator</em>. It shall not appear before the optional <em>cv-qualifier-seq</em> and it shall not appear within the declaration of a static member function<u> of the current class</u> (although its type and value category are defined within a static member function as they are within a non-static member function). [<em>Note</em>: This is because declaration matching does not occur until the complete declarator is known. — <em>end note</em>] [<em>Note</em>: In a <em>trailing-return-type</em>, the class being defined is not required to be complete for purposes of class member access ([expr.ref]). Class members declared later are not visible. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>] — <em>end note</em>]</p>
</blockquote>
<p>Change paragraph 3:</p>
<blockquote>
<p>Otherwise, if a <em>member-declarator</em> declares a non-static data member ([class.mem]) of a class <code>X</code>, the expression <code>this</code> is a prvalue of type “pointer to <code>X</code>”<u> wherever <code>X</code> is the current class</u> within the optional default member initializer ([class.mem]). <s>It shall not appear elsewhere in the <em>member-declarator</em>.</s></p>
</blockquote>
<h4 id="expr.prim.id">[expr.prim.id]</h4>
<!-- TODO: /5: universal overload resolution would just ask "what f?" -->

<h5 id="expr.prim.id.unqual">[expr.prim.id.unqual]</h5>
<p>Change paragraph 2:</p>
<blockquote>
<p>The result is the entity denoted by the <s>identifier</s><u><em>unqualified-id</em> ([basic.lookup.unqual])</u>. If the entity is a local entity […]</p>
</blockquote>
<h5 id="expr.prim.id.qual">[expr.prim.id.qual]</h5>
<p>Change paragraph 1:</p>
<blockquote>
<p><u>The <em>nested-name-specifier</em> <code>::</code> nominates the global namespace.</u> <s>The type denoted by</s><u>A <em>nested-name-specifier</em> with</u> a <em>decltype-specifier</em> <s>in a <em>nested-name-specifier</em></s><u>nominates the type denoted by the <em>decltype-specifier</em>, which</u> shall be a class or enumeration type. <u>Any other <em>nested-name-specifier</em> nominates the entity denoted by its <em>type-name</em>, <em>namespace-name</em>, or terminal name. [<em>Note</em>: In a <em>template-declaration</em>, a <em>type-name</em> that is a <em>simple-template-id</em> can denote a template ([temp.dep.type]). — <em>end note</em>]</u></p>
</blockquote>
<p>Change paragraph 2:</p>
<blockquote>
<p><s>A <em>nested-name-specifier</em> that denotes a class, optionally followed by the keyword <code>template</code> ([temp.names]), and then followed by the name of a member of either that class ([class.mem]) or one of its base classes ([class.derived]), is a <em>qualified-id</em>; [class.qual] describes name lookup for class members that appear in <em>qualified-id</em>⁠s.</s> The result is the <s>member</s><u>entity denoted by the <em>qualified-id</em> ([basic.lookup.qual])</u>. The type of the <s>result</s><u>expression</u> is the type of the <s>member</s><u>result</u>. The result is an lvalue if the member is <u>a function, a variable, a structured binding ([dcl.struct.bind]),</u>a static member function<u>,</u> or a data member and a prvalue otherwise. <s>[<em>Note</em>: A class member can be referred to using a <em>qualified-id</em> at any point in its potential scope ([basic.scope.class]). — <em>end note</em>]</s> <s>Where <em>type-name</em> <code>::~</code> <em>type-name</em> is used, the two <em>type-name</em>⁠s shall refer to the same type (ignoring cv-qualifications); this notation denotes the destructor of the type so named ([expr.prim.id.dtor]).</s> The <em>unqualified-id</em> in a <em>qualified-id</em> shall not be of the form <code>~</code><em>decltype-specifier</em>.</p>
</blockquote>
<p>Remove paragraphs 3 through 5.</p>
<h4 id="expr.prim.lambda">[expr.prim.lambda]</h4>
<h5 id="expr.prim.lambda.closure">[expr.prim.lambda.closure]</h5>
<p>Change paragraph 4:</p>
<blockquote>
<p>[…] <s>[<em>Note</em>: Names referenced in the <em>lambda-declarator</em> are looked up in the context in which the <em>lambda-expression</em> appears. — <em>end note</em>]</s> [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 12:</p>
<blockquote>
<p>The <em>lambda-expression</em>’s <em>compound-statement</em> yields the <em>function-body</em> ([dcl.fct.def]) of the function call operator, but <s>for purposes of name lookup ([basic.lookup]), determining the type and value of <code>this</code> ([class.this]) and transforming <em>id-expression</em>⁠s referring to non-static class members into class member access expressions using <code>(*this)</code> ([class.mfct.non-static]), the <em>compound-statement</em> is considered in the context of the <em>lambda-expression</em></s><u>it is not within the scope of the closure type</u>.<!-- remote --> [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>] Further, a variable <code>__func__</code> is implicitly defined at the beginning of the <em>compound-statement</em> of the <em>lambda-expression</em>, with semantics as described in [dcl.fct.def.general].</p>
</blockquote>
<h5 id="expr.prim.lambda.capture">[expr.prim.lambda.capture]</h5>
<p>Change paragraph 6:</p>
<blockquote>
<p>An <em>init-capture</em> behaves as if it <s>declares and </s>explicitly captures a variable of the form “<code>auto</code> <em>init-capture</em> <code>;</code>” <s>whose declarative region is</s><u>declared in</u> the <em>lambda-expression</em>’s <em>compound-statement</em>, except that:</p>
<p>[…]</p>
</blockquote>
<p>Change paragraph 17:</p>
<blockquote>
<p>A <em>simple-capture</em> followed by an ellipsis is a pack expansion ([temp.variadic]). An <em>init-capture</em> preceded by an ellipsis is a pack expansion that <s>introduces</s><u>declares</u> an <em>init-capture</em> pack ([temp.variadic]) <s>whose declarative region is</s><u>in</u> the <em>lambda-expression</em>’s <em>compound-statement</em>. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<h4 id="expr.prim.req">[expr.prim.req]</h4>
<p>Change the grammar in paragraph 1:</p>
<blockquote>
<p>[…]</p>
<p><em>requirement-parameter-list</em>:</p>
<blockquote>
<p><code>(</code> <em>parameter-declaration-clause</em><sub><s><em>opt</em></s></sub> <code>)</code></p>
</blockquote>
<p>[…]</p>
</blockquote>
<p>Change paragraph 4:</p>
<blockquote>
<p>A <em>requires-expression</em> may introduce local parameters using a <em>parameter-declaration-clause</em> ([dcl.fct]). A local parameter of a <em>requires-expression</em> shall not have a default argument. <s>Each name introduced by a local parameter is in scope from the point of its declaration until the closing brace of the <em>requirement-body</em>.</s> These parameters have no linkage, storage, or lifetime; they are only used as notation for the purpose of defining <em>requirement</em>⁠s. […]</p>
</blockquote>
<p>Remove paragraph 5.</p>
<h3 id="expr.post">[expr.post]</h3>
<h4 id="expr.call">[expr.call]</h4>
<p>Change paragraph 3:</p>
<blockquote>
<p>If <s>a function or member function name is used</s><u>the postfix expression names an overload set</u>, the appropriate function and the validity of the call are determined according to the rules in [over.match]. […]</p>
</blockquote>
<h4 id="expr.ref">[expr.ref]</h4>
<p>Change paragraph 1:</p>
<blockquote>
<p>A postfix expression followed by a dot <code>.</code> or an arrow <code>-&gt;</code>, optionally followed by the keyword <code>template</code><s> ([temp.names])</s>, and then followed by an <em>id-expression</em>, is a postfix expression. The postfix expression before the dot or arrow is evaluated;<sup>[…]</sup> the result of that evaluation, together with the <em>id-expression</em>, determines the result of the entire postfix expression. <u>[<em>Note</em>: If the keyword <code>template</code> is used, the following unqualified name is considered to refer to a template ([temp.names]). If a <em>simple-template-id</em> results and is followed by a <code>::</code>, the <em>id-expression</em> is a <em>qualified-id</em>. — <em>end note</em>]</u></p>
</blockquote>
<p>Change paragraph 4:</p>
<blockquote>
<p>Otherwise, the object expression shall be of class type. The class type shall be complete unless the class member access appears in the definition of that class. [<em>Note</em>: <s>If the class is incomplete, lookup in</s><u>The program is ill-formed if the result differs from that when</u> the<u> class is</u> complete<s> class type is required to refer to the same declaration</s> ([<s>basic.scope.</s>class<u>.member.lookup</u>]). — <em>end note</em>] <s>The <em>id-expression</em> shall name a member of the class or of one of its base classes. [<em>Note</em>: Because the name of a class is inserted in its class scope ([class]), the name of a class is also considered a nested member of that class. — <em>end note</em>]</s> [<em>Note</em>: [basic.lookup.classref] describes how names are looked up after the <code>.</code> and <code>-&gt;</code> operators. — <em>end note</em>]</p>
</blockquote>
<!--
### [expr.unary]
#### [expr.new]
TODO: /11, 26: rephrase in terms of searches; CWG473

#### [expr.delete]
TODO: /9: rephrase in terms of searches -->

<h3 id="expr.const">[expr.const]</h3>
<p>Change bullet (14.7):</p>
<blockquote>
<p>a variable <s>whose name appears as</s><u>named by</u> a potentially constant evaluated expression that is either a constexpr variable or is of non-volatile const-qualified integral type or of reference type.</p>
</blockquote>
<h2 id="stmt.stmt">[stmt.stmt]</h2>
<p>Remove paragraph 5 (whose example is moved to [basic.scope.block]).</p>
<h3 id="stmt.label">[stmt.label]</h3>
<p>Change paragraph 1:</p>
<blockquote>
<p>[…]</p>
<p>The optional <em>attribute-specifier-seq</em> appertains to the label. <s>An <em>identifier label</em> declares the identifier.</s> The only use of a<s>n identifier</s> label<u> with an <em>identifier</em></u> is as the target of a <code>goto</code>. <s>The scope of a label is the function in which it appears. L</s><u>No two l</u>abels <s>shall not be redeclared with</s>in a function<u> shall have the same <em>identifier</em></u>. A label can be used in a <code>goto</code> statement <u>that appears </u>before it<s>s declaration</s>. <s>Labels have their own name space and do not interfere with other identifiers. [<em>Note</em>: A label may have the same name as another declaration in the same scope or a <em>template-parameter</em> from an enclosing scope. Unqualified name lookup ([basic.lookup.unqual]) ignores labels. — <em>end note</em>]</s></p>
</blockquote>
<h3 id="stmt.select">[stmt.select]</h3>
<p>Change paragraph 2:</p>
<blockquote>
<p><s>The substatement in a</s><u>[<em>Note</em>: Each</u> <em>selection-statement</em> <s>(</s><u>and </u>each substatement<s>, in</s><u> of</u> the <code>else</code> form of the <code>if</code> statement<s>)</s> <s>implicitly defines</s><u>has</u> a block scope ([basic.scope<u>.block</u>]).<u> — <em>end note</em>]</u> <s>If the substatement in a <em>selection-statement</em> is a single statement and not a <em>compound-statement</em>, it is as if it was rewritten to be a <em>compound-statement</em> containing the original substatement. [<em>Example</em>:</s></p>
<p><s>[…]</s></p>
<p><s>can be equivalently rewritten as</s></p>
<p><s>[…]</s></p>
<p><s>Thus after the <code>if</code> statement, <code>i</code> is no longer in scope. — <em>end example</em>]</s></p>
</blockquote>
<h4 id="stmt.if">[stmt.if]</h4>
<p>Change paragraph 3:</p>
<blockquote>
<p>[…]</p>
<p>except that <s>names declared in </s>the <em>init-statement</em> <s>are</s><u>is</u> in the same <s>declarative region</s><u>scope</u> as <s>those declared in </s>the <em>condition</em>.</p>
</blockquote>
<h4 id="stmt.switch">[stmt.switch]</h4>
<p>Change paragraph 7 as for [stmt.if]/3.</p>
<h3 id="stmt.iter">[stmt.iter]</h3>
<p>Remove paragraph 3.</p>
<h4 id="stmt.while">[stmt.while]</h4>
<p>Change paragraph 2:</p>
<blockquote>
<p><s>When the condition of a <code>while</code> statement is a declaration, the scope of the variable that is declared extends from its point of declaration ([basic.scope.pdecl]) to the end of the <code>while</code> <em>statement</em>.</s> A <code>while</code> statement is equivalent to</p>
<p>[…]</p>
<p>[<em>Note</em>: The variable created in the condition is destroyed and created with each iteration of the loop. [<em>Example</em>:</p>
<p>[…]</p>
<p>In the while-loop, the constructor and destructor are each called twice, once for the condition that succeeds and once for the condition that fails. — <em>end example</em>] — <em>end note</em>]</p>
</blockquote>
<h4 id="stmt.for">[stmt.for]</h4>
<p>Change paragraph 1 as for [stmt.if]/3 (up to a comma instead of a period).</p>
<p>Remove paragraph 3 (whose example is moved to [basic.scope.block]).</p>
<h3 id="stmt.dcl">[stmt.dcl]</h3>
<p>Change paragraph 1:</p>
<blockquote>
<p>[…]</p>
<p><u>[<em>Note</em>: </u>If an identifier introduced by a declaration was previously declared in an outer block, the outer declaration is hidden for the remainder of the block<u> ([basic.lookup.unqual])</u>, after which it resumes its force.<u> — <em>end note</em>]</u></p>
</blockquote>
<h3 id="stmt.ambig">[stmt.ambig]</h3>
<p>Change paragraph 3:</p>
<blockquote>
<p>[…] Disambiguation precedes parsing, and a statement disambiguated as a declaration may be an ill-formed declaration. If, during parsing, <u>lookup finds that </u>a name in a template <s>parameter is bound differently than it would be bound during a trial parse</s><u>argument is bound to (part of) the declaration being parsed</u>, the program is ill-formed. No diagnostic is required. <s>[<em>Note</em>: This can occur only when the name is declared earlier in the declaration. — <em>end note</em>]</s> [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<h2 id="dcl.dcl">[dcl.dcl]</h2>
<p>Change paragraph 4:</p>
<blockquote>
<p><s>A declaration occurs in a scope ([basic.scope]); the scope rules are summarized in [basic.lookup]. A</s><u>Certain</u> declaration<u>s</u> <s>that declares a function or defines a class, namespace, template, or function also has</s><u>contain</u> one or more scopes<s> nested within it</s><u> ([basic.scope])</u>. <s>These nested scopes, in turn, can have declarations nested within them.</s> Unless otherwise stated, utterances in [dcl.dcl] about components in, of, or contained by a declaration or subcomponent thereof refer only to those components of the declaration that are <em>not</em> nested within scopes nested within the declaration.</p>
</blockquote>
<p>Change paragraph 5:</p>
<blockquote>
<p>In a <em>simple-declaration</em>, the optional <em>init-declarator-list</em> can be omitted only when declaring a class ([class]) or enumeration ([dcl.enum]), that is, when the <em>decl-specifier-seq</em> contains either a <em>class-specifier</em>, an <em>elaborated-type-specifier</em> with a <em>class-key</em> ([class.name]), or an <em>enum-specifier</em>. In these cases and whenever a <em>class-specifier</em> or <em>enum-specifier</em> is present in the <em>decl-specifier-seq</em>, the identifiers in these specifiers are <s>among the names being</s><u>also</u> declared<s> by the declaration</s> (as <em>class-name</em>⁠s, <em>enum-name</em>⁠s, or <em>enumerator</em>⁠s, depending on the syntax). In such cases, the <em>decl-specifier-seq</em> shall introduce one or more names into the program, or shall redeclare <s>a name introduced by </s>a previous declaration. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 9:</p>
<blockquote>
<p>Each <em>init-declarator</em> in the <em>init-declarator-list</em> contains exactly one <em>declarator-id</em><s>, which is the</s><u>. If the <em>declarator-id</em> is a</u> name<u>, the</u> <s>declared by that </s><em>init-declarator</em> and <u>(</u>hence<u>)</u> <s>one of the names declared by </s>the declaration<u> introduce that name</u>. <u>[<em>Note</em>: Otherwise, the <em>declarator-id</em> is a <em>qualified-id</em> or its <em>unqualified-id</em> is a <em>template-id</em> and no name is introduced. — <em>end note</em>]</u> The <em>defining-type-specifier</em>⁠s ([dcl.type]) in the <em>decl-specifier-seq</em> and the recursive <em>declarator</em> structure of the <em>init-declarator</em> describe a type ([dcl.meaning]), which is then associated with the <s>name being declared by the <em>init-declarator</em></s><u><em>declarator-id</em></u>.</p>
</blockquote>
<p>Change paragraph 10:</p>
<blockquote>
<p>If the <em>decl-specifier-seq</em> contains the <code>typedef</code> specifier, the declaration is called a <em>typedef declaration</em><u>, each <em>declarator-id</em> must be an <em>identifier</em>,</u> and <s>the name of </s>each<s> <em>init-declarator</em></s> is declared to be a <em>typedef-name</em>, synonymous with its associated type ([dcl.typedef]). If the <em>decl-specifier-seq</em> contains no <code>typedef</code> specifier, the declaration is called a <em>function declaration</em> if the type associated with <s>the name</s><u>a <em>declarator-id</em></u> is a function type ([dcl.fct]) and an <em>object declaration</em> otherwise.</p>
</blockquote>
<h3 id="dcl.spec">[dcl.spec]</h3>
<!--
#### [dcl.stc]
TODO: /6: consistent linkage -->

<h4 id="dcl.typedef">[dcl.typedef]</h4>
<p>Change paragraph 2:</p>
<blockquote>
<p>A <em>typedef-name</em> can also be introduced by an <em>alias-declaration</em>. The <em>identifier</em> following the <code>using</code> keyword<u> is not looked up; it</u> becomes a <em>typedef-name</em> and the optional <em>attribute-specifier-seq</em> following the <em>identifier</em> appertains to that <em>typedef-name</em>. […]</p>
</blockquote>
<p>Remove paragraphs 3 through 7.</p>
<h4 id="dcl.type">[dcl.type]</h4>
<h5 id="dcl.type.elab">[dcl.type.elab]</h5>
<p>Change paragraph 1:</p>
<blockquote>
<p><s>An <em>attribute-specifier-seq</em> shall not appear in an <em>elaborated-type-specifier</em> unless the latter is the sole constituent of a declaration.</s> If an <em>elaborated-type-specifier</em> is the sole constituent of a declaration, the declaration is ill-formed unless it is an explicit specialization ([temp.expl.spec]), an explicit instantiation ([temp.explicit]) or it has one of the following forms:</p>
<blockquote>
<p><em>class-key</em> <em>attribute-specifier-seq</em><sub><em>opt</em></sub> <em>identifier</em> <code>;</code><br /><u><em>class-key</em> <em>attribute-specifier-seq</em><sub><em>opt</em></sub> <em>simple-template-id</em> <code>;</code></u><br /><s><code>friend</code> <em>class-key</em> <code>::</code><sub><em>opt</em></sub> <em>identifier</em> <code>;</code><br /><code>friend</code> <em>class-key</em> <code>::</code><sub><em>opt</em></sub> <em>simple-template-id</em> <code>;</code><br /><code>friend</code> <em>class-key</em> <em>nested-name-specifier</em> <em>identifier</em> <code>;</code><br /><code>friend</code> <em>class-key</em> <em>nested-name-specifier</em> <code>template</code><sub><em>opt</em></sub> <em>simple-template-id</em> <code>;</code></s></p>
</blockquote>
<p>In the first case, <u>i</u>t<u> declares the <em>identifier</em> as a <em>class-name</em>. The second case shall appear only in a <em>template-declaration</em>; it declares a partial specialization ([temp.class.spec]). T</u>he <em>attribute-specifier-seq</em>, if any, appertains to the class<u> or template</u> being declared<s>; the attributes in the <em>attribute-specifier-seq</em> are thereafter considered attributes of the class whenever it is named</s>.</p>
</blockquote>
<p>Insert before paragraph 2:</p>
<blockquote>
<p>Otherwise, the <em>elaborated-type-specifier</em> shall not have an <em>attribute-specifier-seq</em>. If it contains a <em>identifier</em> but no <em>nested-name-specifier</em> and (unqualified) lookup for the <em>identifier</em> finds nothing, it shall not be introduced by the <code>enum</code> keyword and declares the <em>identifier</em> as a <em>class-name</em>. Its target scope is the nearest enclosing namespace or block scope. If the declaration includes the <code>friend</code> specifier,</p>
<ol style="list-style-type: decimal">
<li>lookup for the <em>identifier</em> does not consider scopes that contain that scope, and</li>
<li>no name is bound.</li>
</ol>
<p>[<em>Note</em>: [basic.lookup.elab] describes how name lookup proceeds in an <em>elaborated-type-specifier</em>. — <em>end note</em>]</p>
</blockquote>
<blockquote>
<p>If it appears with the <code>friend</code> specifier as an entire declaration, the declaration shall have one of the following forms:</p>
<blockquote>
<p><code>friend</code> <em>class-key</em> <em>nested-name-specifier</em><sub><em>opt</em></sub> <em>identifier</em> <code>;</code><br /><code>friend</code> <em>class-key</em> <em>simple-template-id</em> <code>;</code><br /><code>friend</code> <em>class-key</em> <em>nested-name-specifier</em> <code>template</code><sub><em>opt</em></sub> <em>simple-template-id</em> <code>;</code></p>
</blockquote>
</blockquote>
<p>Change paragraph 2:</p>
<blockquote>
<p>[<em>Note</em>: <s>[basic.lookup.elab] describes how name lookup proceeds for the <em>identifier</em> in a</s><u>A</u>n <em>elaborated-type-specifier</em><u> may be used to refer to a previously declared <em>class-name</em> or <em>enum-name</em> even though the name has been hidden by a non-type declaration</u>. — <em>end note</em>] If the <em>identifier</em> or <em>simple-template-id</em> resolves to a <em>class-name</em> or <em>enum-name</em>, the <em>elaborated-type-specifier</em> introduces it into the declaration the same way a <em>simple-type-specifier</em> introduces its <em>type-name</em> ([dcl.type.simple]). […]</p>
</blockquote>
<h5 id="dcl.spec.auto">[dcl.spec.auto]</h5>
<p>Change paragraph 11:</p>
<blockquote>
<p>If <s>the name of</s><u>a <em>primary-expression</em> is an <em>id-expression</em> that refers to</u> an entity with an undeduced placeholder type<s> appears in an expression</s>, the program is ill-formed. Once a non-discarded <code>return</code> statement has been seen in a function, however, the return type deduced from that statement can be used in the rest of the function, including in other <code>return</code> statements. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<h3 id="dcl.decl">[dcl.decl]</h3>
<p>Change paragraph 2:</p>
<blockquote>
<p>The three components of a <em>simple-declaration</em> are the attributes ([dcl.attr]), the specifiers (<em>decl-specifier-seq</em>; [dcl.spec]) and the declarators (<em>init-declarator-list</em>). The specifiers indicate the type, storage class or other properties of the entities being declared. The declarators specify <s>the names of </s>these entities<u> or their names</u> and (optionally) modify the type of the specifiers with operators such as <code>*</code> (pointer to) and <code>()</code> (function returning). Initial values can also be specified in a declarator; initializers are discussed in [dcl.init] and [class.init].</p>
</blockquote>
<h4 id="dcl.meaning">[dcl.meaning]</h4>
<p>Change paragraph 1:</p>
<blockquote>
<p>A declarator contains exactly one <em>declarator-id</em>; it names the <s>identifier</s><u>entity</u> that is declared. An <em>unqualified-id</em> occurring in a <em>declarator-id</em> shall be a simple <em>identifier</em> except for the declaration of some special functions ([class.ctor], [class.conv], [class.dtor], [over.oper]) and for the declaration of template specializations<s> or</s><u>,</u> partial specializations<u>, or explicit instantiations</u> ([temp.spec]). <s>When the <em>declarator-id</em> is qualified, the declaration shall refer to a previously declared member of the class or namespace to which the qualifier refers (or, in the case of a namespace, of an element of the inline namespace set of that namespace ([namespace.def])) or to a specialization thereof; the member shall not merely have been introduced by a <em>using-declaration</em> in the scope of the class or namespace nominated by the <em>nested-name-specifier</em> of the <em>declarator-id</em>.</s> The <em>nested-name-specifier</em> of a qualified <em>declarator-id</em> shall not begin with a <em>decltype-specifier</em>. <s>[<em>Note</em>: If the qualifier is the global <code>::</code> scope resolution operator, the <em>declarator-id</em> refers to a name declared in the global namespace scope. — <em>end note</em>]</s> The optional <em>attribute-specifier-seq</em> following a <em>declarator-id</em> appertains to the entity that is declared.</p>
</blockquote>
<p>Insert before paragraph 2, including the example from [namespace.memdef]/2:</p>
<blockquote>
<p>If the <em>id-expression</em> in a <em>declarator-id</em> is a <em>qualified-id</em> or <em>template-id</em>, or the declaration appears in an <em>explicit-instantiation</em> ([temp.explicit]), let <em>S</em> be the lookup context of the <em>qualified-id</em> ([basic.lookup.qual]), or the smallest enclosing namespace scope if the <em>id-expression</em> is a <em>template-id</em>. The declaration, taken as belonging to <em>S</em> and retaining only the <em>unqualified-id</em> in the <em>declarator-id</em>, shall</p>
<ol style="list-style-type: decimal">
<li>if the <em>unqualified-id</em> is a <em>template-id</em> and the declaration is a friend declaration ([class.friend]), declare a specialization of an entity found by qualified name lookup for the name that is or is in the <em>unqualified-id</em> in <em>S</em>, or else</li>
<li>redeclare or declare a specialization of an entity that belongs to <em>S</em>, or if not that to an element of its inline namespace set if <em>S</em> is a namespace ([namespace.def]).</li>
</ol>
<p>Only entities declared by a declaration that is reachable from the <em>declarator-id</em> and does not belong to a block scope are considered. [<em>Note</em>: The previous declaration might be a friend declaration. — <em>end note</em>] If there is more than one entity that might be redeclared or specialized, the program is ill-formed. If the declaration is not a friend declaration, it shall belong to a namespace that contains the entity. The <em>declarator</em>’s target scope is <em>S</em>; it binds no name. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>[<em>Drafting note</em>: Richard proposed making the restriction on use of a <em>qualified-id</em> grammatical. — <em>end drafting note</em>]</p>
<p>(The example below is moved from [basic.link]/9, with changes as marked.)</p>
<blockquote>
<p>If the <em>id-expression</em> in a <em>declarator-id</em> is a name, the name is not looked up.</p>
<ol style="list-style-type: decimal">
<li>If the declaration is a friend declaration, its target scope is the smallest enclosing namespace or block scope; in the latter case, the declaration shall redeclare a function with a reachable declaration belonging to that scope. The <em>declarator</em> binds no name.</li>
<li>If the declaration belongs to a block scope and declares a function ([dcl.fct]) or uses the <code>extern</code> specifier, the declaration shall not be attached to a named module ([module.unit]) and its target scope is the smallest enclosing namespace scope, but the name is bound in its enclosing scope. [<em>Example</em>:<!-- FIXME: the <pre> shouldn't be outside the list --></li>
</ol>
<pre class="cpp">
namespace X {
  void p() {
    q();                        // error: q not yet declared
    extern void q();            // q is a member of namespace X<u>
    extern void r();            // r is a member of namespace X</u>
  }

  void middle() {
    q();                        // error: q not <s>yet declared</s><u>found</u>
  }

  void q() { /* ... */ }        // definition of X::q
}

void q() { /* ... */ }          // some other, unrelated q<u>
void X::r() { /* ... */ } // error: r cannot be declared by qualified-id</u>
</pre>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 3:</p>
<blockquote>
<p>Thus, <u>(for each <em>init-declarator</em>) </u>a declaration<s> of a particular identifier</s> has the form</p>
<pre class="sourceCode cpp"><code class="sourceCode cpp">T D</code></pre>
<p>where <code>T</code> is of the form <em>attribute-specifier-seq</em><sub><em>opt</em></sub> <em>decl-specifier-seq</em> and <code>D</code> is a declarator. Following is a recursive procedure for determining the type specified for the contained <em>declarator-id</em> by such a declaration.</p>
</blockquote>
<p>Change paragraph 5:</p>
<blockquote>
<p>In a declaration <em>attribute-specifier-seq</em><sub><em>opt</em></sub> <code>T</code> <code>D</code> where <code>D</code> is an unadorned <s>identifier</s><u>name</u> the type of this identifier is “<code>T</code>”.</p>
</blockquote>
<h5 id="dcl.fct">[dcl.fct]</h5>
<!-- TODO: /10: function identity -->

<p>Change paragraph 15:</p>
<blockquote>
<p>An identifier can optionally be provided as a parameter name; if present in a function definition ([dcl.fct.def]), it names a parameter. [<em>Note</em>: In particular, parameter names are also optional in function definitions and names used for a parameter in different declarations and the definition of a function need not be the same. If a parameter name is present in a function declaration that is not a definition, it cannot be used outside of its function declarator because that is the extent of <s>its potential</s><u>the enclosing</u> scope ([basic.scope.param]). — <em>end note</em>]</p>
</blockquote>
<h5 id="dcl.fct.default">[dcl.fct.default]</h5>
<p>Change paragraph 5:</p>
<blockquote>
<p>The default argument has the same semantic constraints as the initializer in a declaration of a variable of the parameter type, using the copy-initialization semantics ([dcl.init]). The names in the default argument are <s>bound</s><u>looked up</u>, and the semantic constraints are checked, at the point where the default argument appears. Name lookup and checking of semantic constraints for default arguments in function templates and in member functions of class templates are performed as described in [temp.inst]. [<em>Example</em>: In the following code, <code>g</code> will be called with the value <code>f(2)</code>:</p>
<p>[…]</p>
<p>— <em>end example</em>] [<em>Note</em>: <s>In member function declarations, names in default arguments are looked up as described in [basic.lookup.unqual].</s> Access checking applies to names in default arguments as described in [class.access]. — <em>end note</em>]</p>
</blockquote>
<p>Change paragraph 9:</p>
<blockquote>
<p>A default argument is evaluated each time the function is called with no argument for the corresponding parameter. A parameter shall not appear as a potentially-evaluated expression in a default argument. <u>[<em>Note</em>: </u>Parameters of a function declared before a default argument are in scope and can hide namespace and class member names.<u> — <em>end note</em>]</u> [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>] A non-static member shall not appear in a default argument unless it appears as the <em>id-expression</em> of a class member access expression ([expr.ref]) or unless it is used to form a pointer to member ([expr.unary.op]). [<em>Example</em>: The declaration of <code>X::mem1()</code> in the following example is ill-formed because no object is supplied for the non-static member <code>X::a</code> used as an initializer.</p>
<p>[…]</p>
<p>The declaration of <code>X::mem2()</code> is meaningful, however, since no object is needed to access the static member <code>X::b</code>. Classes, objects, and members are described in [class]. — <em>end example</em>] A default argument is not part of the type of a function. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>] When a declaration of a function<u> in a scope <em>S</em></u> is <s>introduced</s><u>named</u> by <s>way of </s>a <em>using-declarat<s>ion</s><u>or</u></em> ([namespace.udecl]), any default argument<s> information</s> associated with <s>the</s><u>any</u> declaration <s>is made known as well</s><u><em>D</em> in <em>S</em> is available to any call from which <em>D</em> is reachable</u>. <s>If the function is redeclared thereafter in the namespace with additional default arguments, the additional arguments are also known at any point following the redeclaration where the <em>using-declaration</em> is in scope.</s> <u>[<em>Note</em>: <em>D</em> need not be reachable from the <em>using-declaration</em>. — <em>end note</em>]</u></p>
</blockquote>
<h3 id="dcl.init">[dcl.init]</h3>
<p>Remove paragraph 13.</p>
<h4 id="dcl.init.aggr">[dcl.init.aggr]</h4>
<p>Change bullet (4.1):</p>
<blockquote>
<p>If the element is an anonymous union <s>object</s><u>variable</u> and the initializer list is a <em>designated-initializer-list</em>, the anonymous union <s>object</s><u>variable</u> is initialized by the <em>designated-initializer-list</em> <code>\{</code><em>D</em><code>\</code>}, where <em>D</em> is the <em>designated-initializer-clause</em> naming a member of the anonymous union <s>object</s><u>variable</u>. […]</p>
</blockquote>
<h3 id="enum">[enum]</h3>
<h4 id="dcl.enum">[dcl.enum]</h4>
<p>Change paragraph 4:</p>
<blockquote>
<p>If an <em>enum-head-name</em> contains a <em>nested-name-specifier</em>, it shall not begin with a <em>decltype-specifier</em> and <s>the enclosing <em>enum-specifier</em> or <em>opaque-enum-declaration</em> shall refer to an</s><u>there shall be a preceding declaration of the</u> enumeration that <s>was previously declared directly in</s><u>belongs to the scope of</u> the class<u> (template)</u> or namespace to which the <em>nested-name-specifier</em> refers, or in an element of the inline namespace set ([namespace.def]) of that namespace<s> (i.e., neither inherited nor introduced by a <em>using-declaration</em>)</s>, and the <em>enum-specifier</em> or <em>opaque-enum-declaration</em> shall appear in a namespace<u> scope</u> enclosing the previous declaration.</p>
</blockquote>
<p>Change paragraph 6:</p>
<blockquote>
<p>An enumeration whose underlying type is fixed is an incomplete type <s>from its point of declaration ([basic.scope.pdecl]) to</s><u>until</u> immediately after its <em>enum-base</em> (if any), at which point it becomes a complete type. An enumeration whose underlying type is not fixed is an incomplete type <s>from its point of declaration to immediately after</s><u>until</u> the closing <code>}</code> of its <em>enum-specifier</em>, at which point it becomes a complete type.</p>
</blockquote>
<p>Change paragraph 11:</p>
<blockquote>
<p><s>Each <em>enum-name</em> and</s><u>The name of</u> each unscoped <s><em>enumerator</em></s><u>enumerator</u> is <s>declared</s><u>also bound</u> in the scope that immediately contains the <em>enum-specifier</em>. <s>Each scoped <em>enumerator</em> is declared in the scope of the enumeration. These names obey the scope rules defined for all names in [basic.scope] and [basic.lookup].</s> [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>] <s>An enumerator declared in class scope can be referred to using the class member access operators (<code>::</code>, <code>.</code> (dot) and <code>-&gt;</code> (arrow)), see [expr.ref]. [<em>Example</em>:</s></p>
<p><s>[…]</s></p>
<p><s>— <em>end example</em>]</s></p>
</blockquote>
<h4 id="enum.udecl">[enum.udecl]</h4>
<p>Change paragraph 2:</p>
<blockquote>
<p>A <em>using-enum-declaration</em> <s>introduces the enumerator names of the named enumeration as if by</s><u>is equivalent to</u> a <em>using-declaration</em> for each enumerator.</p>
</blockquote>
<p>Change paragraph 3:</p>
<blockquote>
<p>[<em>Note</em>: A <em>using-enum-declaration</em> in class scope <s>adds</s><u>makes</u> the enumerators of the named enumeration <s>as members to the scope. This means they are accessible for</s><u>available via</u> member lookup. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>] — <em>end note</em>]</p>
</blockquote>
<h3 id="basic.namespace">[basic.namespace]</h3>
<p>Change paragraph 1:</p>
<blockquote>
<p>A namespace is an optionally-named <s>declarative region</s><u>entity whose scope can contain declarations of any kind of entity</u>. The name of a namespace can be used to access entities <s>declared in</s><u>that belong to</u> that namespace; that is, the <s>members</s><u><em>members</em></u> of the namespace. Unlike other <s>declarative regions</s><u>entities</u>, the definition of a namespace can be split over several parts of one or more translation units<u> and modules</u>.</p>
</blockquote>
<p>Change paragraph 2:</p>
<blockquote>
<p>[<em>Note</em>: A <s>namespace name with external linkage</s><u><em>namespace-definition</em></u> is exported if <s>any of its <em>namespace-definition</em>⁠s</s><u>it</u> is exported<s>,</s> or <s>if it </s>contains any <em>export-declaration</em>⁠s ([module.interface]). A namespace is never attached to a module, and <u>its name </u>never has module linkage<s> even if it is not exported</s>. — <em>end note</em>] [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 3:</p>
<blockquote>
<p>The<s> outermost declarative region of a translation unit</s><u>re</u> is a <s>namespace</s><u><em>global namespace</em> with no name and no declaration</u>; see [basic.scope.namespace].</p>
</blockquote>
<h4 id="namespace.def">[namespace.def]</h4>
<!-- TODO: /2: use simpler lookup, but https://lists.isocpp.org/core/2019/05/6121.php; maybe use "element" instead of "member" -->
<!-- TODO: /4: what does this mean, if anything? -->

<p>Change paragraph 1:</p>
<blockquote>
<p>Every <em>namespace-definition</em> shall appear <s>in the global scope or </s>in a namespace scope ([basic.scope.namespace]).</p>
</blockquote>
<p>Change paragraph 7:</p>
<blockquote>
<p>Members of an inline namespace can be used in most respects as though they were members of the enclosing namespace. Specifically, <s>the inline namespace and </s>its enclosing namespace <s>are both added to the set of</s><u>is an</u> associated namespace<s>s</s> used in argument-dependent lookup ([basic.lookup.argdep]) <s>whenever one of them is</s><u>if a member is an associated entity</u>, and a <em>using-directive</em> ([namespace.udir]) that names the inline namespace is implicitly inserted into the enclosing namespace as for an unnamed namespace ([namespace.unnamed]). Furthermore, each member of the inline namespace can subsequently be partially specialized ([temp.class.spec]), explicitly instantiated ([temp.explicit]), or explicitly specialized ([temp.expl.spec]) as though it were a member of the enclosing namespace. Finally, looking up a name in the enclosing namespace via explicit qualification ([namespace.qual]) will include members of the inline namespace<s> brought in by the <em>using-directive</em></s> even if there are declarations of that name in the enclosing namespace.</p>
</blockquote>
<p>Change paragraph 8:</p>
<blockquote>
<p>These properties are transitive: if a namespace <code>N</code> contains an inline namespace <code>M</code>, which in turn contains an inline namespace <code>O</code>, then the members of <code>O</code> can be used as though they were members of <code>M</code> or <code>N</code>. The <em>inline namespace set</em> of <code>N</code> is the transitive closure of all inline namespaces in <code>N</code>. <s>The <em>enclosing namespace set</em> of <code>O</code> is the set of namespaces consisting of the innermost non-inline namespace enclosing an inline namespace <code>O</code>, together with any intervening inline namespaces.</s></p>
</blockquote>
<h5 id="namespace.memdef">[namespace.memdef]</h5>
<p>Remove subclause, referring the stable name to [namespace.def]. Remove the cross references in [namespace.def]/4 and [class.compare.default]/2, and update those in [temp.class.spec]/6 and [temp.expl.spec]/2 to refer to [dcl.meaning].</p>
<p>The examples in paragraphs 2 and 3 are moved to [dcl.meaning] and [class.friend]/11 respectively.</p>
<!--
#### [namespace.alias]
TODO: /3: probably unnecessary (note that GCC disagrees with other compilers about "namespace A {}; namespace A = A;" but might be right if we simplify this, but then [namespace.def]/2 could be broken) -->

<h4 id="namespace.udir">[namespace.udir]</h4>
<p>Remove paragraph 2.</p>
<p>Change paragraph 3:</p>
<blockquote>
<p>A <em>using-directive</em> does not <s>add any members to the declarative region in which it appears</s><u>bind any names</u>. <u>[<em>Note</em>: Instead, unqualified and qualified lookup search the namespace nominated by a <em>using-directive</em> (including for further <em>using-directive</em>⁠s) when considering certain scopes that contain it ([basic.lookup.unqual], [basic.lookup.qual]). — <em>end note</em>]</u> [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Remove paragraphs 4 and 5.</p>
<p>Change paragraph 7:</p>
<blockquote>
<p><s>During overload resolution, all functions from the transitive search are considered for argument matching. The set of declarations found by the transitive search is unordered.</s> [<em>Note</em>: <s>In particular, t</s><u>T</u>he order in which namespaces <s>we</s><u>a</u>re considered and the relationships among the namespaces implied by the <em>using-directive</em>⁠s do not <s>cause preference to be given to any of the declarations found by the search</s><u>affect overload resolution</u>.<s> — <em>end note</em>]</s> <s>An ambiguity exists if the best match finds two functions with</s><u>Neither is any function excluded because another has</u> the same signature, even if one is in a namespace reachable through <em>using-directive</em>⁠s in the namespace of the other.<sup>[…]</sup><u> — <em>end note</em>]</u> [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<h4 id="namespace.udecl">[namespace.udecl]</h4>
<p>Change and split paragraph 1:</p>
<blockquote>
<p>Each <em>using-declarator</em> in a <em>using-declaration</em><sup>[…]</sup> <s>introduces a set of declarations into the declarative region in which the <em>using-declaration</em> appears. The</s><u>names the</u> set of declarations<s> introduced by the <em>using-declarator</em> is</s> found by performing qualified name lookup ([basic.lookup.qual], [class.member.lookup]) for <s>the name in the </s><em>using-declarator</em>, <s>excluding</s><u>except that class and enumeration declarations that would be discarded are merely ignored when checking for ambiguity ([basic.lookup]), conversion function templates are ignored, and certain</u> functions <s>that </s>are hidden as described below.<!-- remote --> <u>If the <em>using-declarator</em> is a qualified dependent name ([temp.dep.type]), it is considered to name a constructor if and only if the <em>unqualified-id</em> is the same as the terminal name of the <em>nested-name-specifier</em>. If the lookup in any instantiation finds that a <em>using-declarator</em> that is not considered to name a constructor does do so, or that a <em>using-declarator</em> that is considered to name a constructor does not, the program is ill-formed.</u></p>
</blockquote>
<blockquote>
<p>If the <em>using-declarator</em> does not name a constructor, the <em>unqualified-id</em> is <s>declared in the declarative region in which the <em>using-declaration</em> appears as a synonym for each declaration introduced by</s><u>bound to</u> the <em>using-declarator</em>. [<em>Note</em>: Only the specified name is so <s>declared</s><u>bound</u>; specifying an enumeration name in a <em>using-declaration</em> does not <s>declare</s><u>bind the names of</u> its enumerators<s> in the <em>using-declaration</em>’s declarative region</s>. <u>During name lookup, the <em>using-declarator</em> is replaced with the declarations it names ([basic.lookup]).</u> — ⁠<em>end note</em>] If the <em>using-declarator</em> names a constructor, it declares that the class <em>inherits</em> the <u>named </u>set of constructor declarations<s> introduced by the <em>using-declarator</em></s> from the nominated base class. <u>[<em>Note</em>: For the keyword <code>typename</code>, see [temp.res]. — <em>end note</em>]</u></p>
</blockquote>
<p>Remove paragraph 2.</p>
<p>Change paragraph 3:</p>
<blockquote>
<p>In a <em>using-declaration</em> used as a <em>member-declaration</em>, each <em>using-declarator</em> shall either name an enumerator or have a <em>nested-name-specifier</em> naming a base class of the <u>enclosing </u>class<s> being defined</s>. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>] If a <em>using-declarator</em> names a constructor, its <em>nested-name-specifier</em> shall name a direct base class of the <u>enclosing </u>class<s> being defined</s>. <u>If the enclosing class scope is associated with a class template, it shall derive from the specified base class or have at least one dependent base class.</u> [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>] [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 4:</p>
<blockquote>
<p>[<em>Note</em>: Since destructors do not have names, a <em>using-declaration</em> cannot refer to a destructor for a base class. <s>Since specializations of member templates for conversion functions are not found by name lookup, they are not considered when a <em>using-declaration</em> specifies a conversion function ([temp.mem]).</s> — <em>end note</em>] If a constructor or assignment operator brought from a base class into a derived class has the signature of a copy/move constructor or assignment operator for the derived class ([class.copy.ctor], [class.copy.assign]), the <em>using-declaration</em> does not by itself suppress the implicit declaration of the derived class member; the member from the base class is hidden or overridden by the implicitly-declared copy/move constructor or assignment operator of the derived class, as described below.</p>
</blockquote>
<p>Remove paragraph 8.</p>
<p>Replace paragraph 9:</p>
<blockquote>
<p>If a declaration is named by two <em>using-declarator</em>⁠s that belong to the same class scope, the program is ill-formed.</p>
</blockquote>
<p>Change paragraph 10:</p>
<blockquote>
<p>[<em>Note</em>: <s>For a</s><u>A</u> <em>using-declarat<s>ion</s><u>or</u></em> whose <em>nested-name-specifier</em> names a namespace<s>, members</s><u> does not name declarations</u> added to the namespace after <s>the <em>using-declaration</em> are not in the set of introduced declarations, so they are not considered when a use of the name is made</s><u>it</u>. Thus, additional overloads added after the <em>using-declaration</em> are ignored, but default function arguments ([dcl.fct.default]), default template arguments ([temp.param]), and template specializations ([temp.class.spec], [temp.expl.spec]) are considered. — <em>end note</em>] [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 12:</p>
<blockquote>
<s>Since a <em>using-declaration</em> is a declaration, the restrictions on declarations of the same name in the same declarative region ([basic.scope]) also apply to <em>using-declaration</em>⁠s.</s> <u>A declaration named by a <em>using-declaration</em> that belongs to a scope <em>S</em> shall not conflict with another whose target scope is <em>S</em>. Two declarations named by <em>using-declaration</em>⁠s that belong to a scope shall not conflict unless they both declare functions or function templates. [<em>Note</em>: Overload resolution may not be able to distinguish between conflicting function declarations. — <em>end note</em>]</u><!-- BUG: MMMM (modules and sometimes-NDR)? --> [<em>Example</em>:
<pre class="cpp">
namespace A {
  int x;
<u>  int f(int);
  int g;
  void h();
</u>}

namespace B {
  int i;
  struct g { };
  struct x { };
  void f(int);
  void f(double);
  void g(char);     // OK: hides struct g
}

void func() {
  int i;
  using B::i;       // error: <s>i declared twice</s><u>conflicts</u>
  void f(char);
  using B::f;       // OK: each f is a function
<u>  using A::f;       // OK, but merely prevents calling B::f(int)
  f(1);             // error: ambiguous
</u>  f(3.5);           // calls B::f(double)
  using B::g;
  g('a');           // calls B::g(char)
  struct g g1;      // g1 has class type B::g
<u>  using A::g;       // error: conflicts with B::g
  void h();
  using A::h;       // error: conflicts
</u>  using B::x;
  using A::x;       // OK: hides struct B::x
  x = 99;           // assigns to A::x
  struct x x1;      // x1 has class type B::x
}
</pre>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Remove paragraph 13 (whose example is merged into the above).</p>
<p>Change paragraph 14:</p>
<blockquote>
<p><s>When</s><u>The set of declarations named by</u> a <em>using-declarator</em> <s>brings declarations from a base class into a derived class,</s><u>that belongs to a class <code>C</code> does not include</u> member functions and member function templates <s>in the derived</s><u>of a base</u> class <s>override and/or hide</s><u>for which <code>C</code> declares</u> member functions and member function templates with the same name, parameter-type-list ([dcl.fct]), cv-qualification, and <em>ref-qualifier</em> (if any)<s> in a base class (rather than conflicting)</s>.<!-- TODO: function identity --> <s>Such hidden or overridden declarations are excluded from the set of declarations introduced by the <em>using-declarator</em>.</s> [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Chnage paragraph 16:</p>
<blockquote>
<p>Constructors that are <s>introduced</s><u>named</u> by a <em>using-declaration</em> are treated as though they were constructors of the derived class when looking up the constructors of the derived class ([class.qual]) or forming a set of overload candidates ([over.match.ctor], [over.match.copy], [over.match.list]).<!-- remote --> [<em>Note</em>: If such a constructor is selected to perform the initialization of an object of class type, all subobjects other than the base class from which the constructor originated are implicitly initialized ([class.inhctor.init]). A constructor of a derived class is sometimes preferred to a constructor of a base class if they would otherwise be ambiguous ([over.match.best]). — <em>end note</em>]</p>
</blockquote>
<p>Change paragraph 17:</p>
<blockquote>
<p>In a <em>using-declarator</em> that does not name a constructor, <s>all members of the set of introduced</s><u>every</u> declaration<s>s</s><u> named</u> shall be accessible. In a <em>using-declarator</em> that names a constructor, no access check is performed. <s>In particular, if a derived class uses a <em>using-declarator</em> to access a member of a base class, the member name shall be accessible. If the name is that of an overloaded member function, then all functions named shall be accessible.</s> <s>The</s><u>Every</u> base class member<s>s</s> <s>mentioned</s><u>named</u> by a <em>using-declarator</em> shall be <s>visible in the scope</s><u>a result</u> of <u>a search for the terminal name of the <em>using-declarator</em> in </u>at least one of the direct base classes of the class <s>where</s><u>to which</u> the <em>using-declarator</em> <s>is specified</s><u>belongs</u>.</p>
</blockquote>
<p>Change paragraph 19:</p>
<blockquote>
<p>A <s>synonym created by a </s><em>using-declaration</em> has the usual accessibility for a <em>member-declaration</em>. <s>A</s><u>Base-class constructors considered because of a</u> <em>using-declarator</em><s> that names a constructor does not create a synonym; instead, the additional constructors</s> are accessible if they would be accessible when used to construct an object of the <s>corresponding </s>base class<s>, and</s><u>;</u> the accessibility of the <em>using-declaration</em> is ignored. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Remove paragraph 21.</p>
<h4 id="dcl.link">[dcl.link]</h4>
<!-- TODO: only namespace-scope things need language linkage at all -->

<p>Change paragraph 4:</p>
<blockquote>
<p>Linkage specifications nest. When linkage specifications nest, the innermost one determines the language linkage. <u>[<em>Note</em>: </u>A linkage specification does not establish a scope.<u> — <em>end note</em>]</u> A <em>linkage-specification</em> shall <s>occur only in</s><u>belong to a</u> namespace scope ([basic.scope]). In a <em>linkage-specification</em>, the specified language linkage applies to the function types of all function declarators, function names with external linkage, and variable names with external linkage declared within the <em>linkage-specification</em>. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>] A C language linkage is ignored in determining the language linkage of the names of class members and the function type of class member functions. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 5:</p>
<blockquote>
<p>If two declarations declare functions with the same name and parameter-type-list ([dcl.fct]) to be members of the same namespace or declare objects with the same name to be members of the same namespace and the declarations give the names different language linkages, the program is ill-formed; no diagnostic is required if the declarations appear in different translation units. <s>Except for functions with C++ linkage, a function declaration without a linkage specification shall not precede the first linkage specification for that function.</s> A<u> redeclaration of a</u> function <s>can be declared </s>without a linkage specification <s>after an explicit linkage specification has been seen; the linkage explicitly specified in the earlier declaration is</s><u>does</u> not affect<s>ed by such a function declaration</s><u> its language linkage</u>. <!-- TODO: function identity --></p>
</blockquote>
<h2 id="module">[module]</h2>
<h3 id="module.interface">[module.interface]</h3>
<p>Change paragraph 1:</p>
<blockquote>
<p>An <em>export-declaration</em> shall <s>appear only at</s><u>belong to a</u> namespace scope and <s>only</s><u>appear</u> in the purview of a module interface unit. An <em>export-declaration</em> shall not appear directly or indirectly within an unnamed namespace or a <em>private-module-fragment</em>. An <em>export-declaration</em> has the declarative effects of its <em>declaration</em> or its <em>declaration-seq</em> (if any). <s>An <em>export-declaration</em> does not establish a scope and its</s><u>The</u> <em>declaration</em> or <em>declaration-seq</em><u> of an <em>export-declaration</em></u> shall not contain an <em>export-declaration</em>. <u>[<em>Note</em>: An <em>export-declaration</em> does not establish a scope.</u></p>
</blockquote>
<h3 id="module.import">[module.import]</h3>
<p>Change paragraph 1:</p>
<blockquote>
<p>In a module unit, all <em>module-import-declaration</em>⁠s shall <s>precede</s><u>appear before</u> all other <em>top-level-declaration</em>⁠s in the <em>top-level-declaration-seq</em> of the <em>translation-unit</em> and of the <em>private-module-fragment</em> (if any). The optional <em>attribute-specifier-seq</em> appertains to the <em>module-import-declaration</em>.</p>
</blockquote>
<p>Change paragraph 2:</p>
<blockquote>
<p>A <em>module-import-declaration</em> <em>imports</em> a set of translation units determined as described below. [<em>Note</em>: Namespace-scope names exported by the imported translation units <s>become visible</s><u>can be found by name lookup</u> ([basic.<s>scope.namespace</s><u>lookup</u>]) in the importing translation unit and declarations within the imported translation units become reachable ([module.reach]) in the importing translation unit after the import declaration. — <em>end note</em>]</p>
</blockquote>
<h3 id="module.context">[module.context]</h3>
<p>Change paragraph 1:</p>
<blockquote>
<p>The <em>instantiation context</em> is a set of points within the program that determines which <s>names</s><u>declarations</u> are <s>visible to</s><u>found by</u> argument-dependent name lookup ([basic.lookup.argdep]) and which <s>declarations </s>are reachable ([module.reach]) in the context of a particular declaration or template instantiation.</p>
</blockquote>
<h3 id="module.reach">[module.reach]</h3>
<p>Change paragraph 1:</p>
<blockquote>
<p>A translation unit <em>U</em> is <em>necessarily reachable</em> from a point <em>P</em> if <em>U</em> is a module interface unit on which the translation unit containing <em>P</em> has an interface dependency, or the translation unit containing <em>P</em> imports <em>U</em>, in either case prior to <em>P</em> ([module.import]). [<em>Note</em>: While module interface units are reachable even when they are only transitively imported via a non-exported import declaration, namespace-scope names from such module interface units are not <s>visible to</s><u>found by</u> name lookup ([basic.<s>scope.namespace</s><u>lookup</u>]). — <em>end note</em>]</p>
</blockquote>
<p>Change paragraph 4:</p>
<blockquote>
<p>The accumulated properties of all reachable declarations of an entity within a context determine the behavior of the entity within that context. [<em>Note</em>: These reachable semantic properties include type completeness, type definitions, initializers, default arguments of functions or template declarations, attributes, <s>visibility of class or enumeration member </s>names <s>to ordinary lookup</s><u>bound</u>, etc. Since default arguments are evaluated in the context of the call expression, the reachable semantic properties of the corresponding parameter types apply in that context. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>] — <em>end note</em>]</p>
</blockquote>
<p>Change paragraph 5:</p>
<blockquote>
<p>[<em>Note</em>: An entity can have reachable declarations even if <s>it is not visible to</s><u>no declaration of it can be found by</u> name lookup. — <em>end note</em>] [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<h2 id="class">[class]</h2>
<p>Change paragraph 1:</p>
<blockquote>
<p>[…]</p>
<p>A class declaration where the <em>class-name</em> in the <em>class-head-name</em> is a <em>simple-template-id</em> shall be an explicit specialization ([temp.expl.spec]) or a partial specialization ([temp.class.spec]). <u>Otherwise, the <em>identifier</em> is not looked up.</u> A <em>class-specifier</em> whose <em>class-head</em> omits the <em>class-head-name</em> defines an unnamed class. [<em>Note</em>: An unnamed class thus can’t be <code>final</code>. — <em>end note</em>]</p>
</blockquote>
<p>Change paragraph 2:</p>
<blockquote>
<p>A <em>class-name</em> is<s> inserted into the scope in which it is declared immediately after the <em>class-name</em> is seen. The <em>class-name</em> is</s> also <s>inserted into</s><u>bound in</u> the scope of the class itself; this is known as the <em>injected-class-name</em>. […]</p>
</blockquote>
<p>Change paragraph 3:</p>
<blockquote>
<p>If a <em>class-head-name</em> contains a <em>nested-name-specifier</em>, <u>there shall be a preceding declaration of </u>the<s> <em>class-specifier</em> shall refer to a</s> class that <s>was previously declared directly in</s><u>belongs to the scope of</u> the class<u> (template)</u> or namespace to which the <em>nested-name-specifier</em> refers, or in an element of the inline namespace set ([namespace.def]) of that namespace<s> (i.e., not merely inherited or introduced by a <em>using-declaration</em>)</s>, and the <em>class-specifier</em> shall appear in a namespace<u> scope</u> enclosing the previous declaration. In such cases, the <em>nested-name-specifier</em> of the <em>class-head-name</em> of the definition shall not begin with a <em>decltype-specifier</em>.</p>
</blockquote>
<h3 id="class.name">[class.name]</h3>
<p>Change paragraph 2:</p>
<blockquote>
<p><s>A class declaration introduces the class name into the scope where it is declared and hides any class, variable, function, or other declaration of that name in an enclosing scope ([basic.scope]).</s> <s>If</s><u>[<em>Note</em>: It may be necessary to use an <em>elaborated-type-specifier</em> to refer to</u> a class <s>name is declared in</s><u>that belongs to</u> a scope <s>where</s><u>to which</u> a variable, function, or enumerator of the same name <s>is </s>also <s>declared, then when both declarations are in scope, the class can be referred to only using an <em>elaborated-type-specifier</em></s><u>belongs</u> ([basic.lookup.elab]). [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]<u> — <em>end note</em>] [<em>Note</em>: </u>A<u>n <em>elaborated-type-specifier</em></u> <s><em>declaration</em> consisting solely of <em>class-key</em> <em>identifier</em><code>;</code> is either a redeclaration of the name in the current scope or a forward declaration of the</s><u>may also be used to declare an</u> identifier as a class name. <s>It introduces the class name into the current scope.</s> [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]<u> — <em>end note</em>]</u> [<em>Note</em>: Such declarations allow definition of classes that refer to each other. [<em>Example</em>:</p>
<p>[…]</p>
<p>Declaration of friends is described in [class.friend], operator functions in [over.oper]. — <em>end example</em>] — <em>end note</em>]</p>
</blockquote>
<h3 id="class.mem">[class.mem]</h3>
<p>Change paragraph 1:</p>
<blockquote>
<p>[…] A <em>direct member</em> of a class <code>X</code> is a member of <code>X</code> that was first declared within the <em>member-specification</em> of <code>X</code>, including anonymous union <s>objects</s><u>variables</u> ([class.union.anon]) and direct members thereof. […]</p>
</blockquote>
<p>Insert before paragraph 6:</p>
<blockquote>
<p>A <em>closed context</em> of a class (template) is a function body ([dcl.fct.def.general]) or <em>noexcept-specifier</em> ([except.spec]) within its <em>member-specification</em>.</p>
</blockquote>
<p>Change paragraph 6:</p>
<blockquote>
<p>A <em>complete-class context</em> of a class<u> (template)</u> is <u>a closed context of the entity or </u>a</p>
<ol style="list-style-type: decimal">
<li><s>function body ([dcl.fct.def.general]),</s></li>
<li>default argument ([dcl.fct.default]),</li>
<li><s><em>noexcept-specifier</em> ([except.spec])</s><u>default template argument ([temp.param])</u>, or</li>
<li>default member initializer</li>
</ol>
<p>within the <em>member-specification</em> of the class<u> or class template</u>. [<em>Note</em>: […] — <em>end note</em>][…]</p>
</blockquote>
<h4 id="class.mfct">[class.mfct]</h4>
<p>Change paragraph 1:</p>
<blockquote>
<p><s>A</s><u>If a</u> member function <s>may be</s><u>is</u> defined ([dcl.fct.def]) in its class definition, <s>in which case </s>it is an inline member function ([dcl.inline])<s>, or it may be defined outside of its class definition if it has already been declared but not defined in its class definition</s>. <s>A member function definition that appears outside of the class definition shall appear in a namespace scope enclosing the class definition.</s> Except for member function definitions that appear outside of a class definition, and except for explicit specializations of member functions of class templates and member function templates ([temp.spec]) appearing outside of the class definition, a member function shall not be redeclared.</p>
</blockquote>
<p>Remove paragraph 4 except for its example.</p>
<h4 id="class.this">[class.this]</h4>
<p>Remove paragraphs 1 and 2.</p>
<!-- TODO: /3: universal overload resolution would reject these -->

<h4 id="class.ctor">[class.ctor]</h4>
<p>Change paragraph 2:</p>
<blockquote>
<p>A constructor is used to initialize objects of its class type. <u>[<em>Note</em>: </u>Because constructors do not have names, they are never found during <u>unqualified </u>name lookup; however an explicit type conversion using the functional notation ([expr.type.conv]) will cause a constructor to be called to initialize an object. <s>[<em>Note</em>: </s>The syntax looks like an explicit call of the constructor. — <em>end note</em>] [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>] [<em>Note</em>: For initialization of objects of class type see [class.init]. — <em>end note</em>]</p>
</blockquote>
<h4 id="class.conv">[class.conv]</h4>
<p>Change paragraph 5:</p>
<blockquote>
<p><s>User-defined conversions are used implicitly only if they are unambiguous.</s> <u>[<em>Note</em>: </u>A conversion function in a derived class does not hide a conversion function in a base class unless the two functions convert to the same type. Function overload resolution ([over.match.best]) selects the best conversion function to perform the conversion.<u> — <em>end note</em>]</u> [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<h5 id="class.conv.fct">[class.conv.fct]</h5>
<p>Change paragraph 1:</p>
<blockquote>
<p>[…] specifies a conversion from <code>X</code> to the type specified by the <em>conversion-type-id</em><u>, interpreted as a <em>type-id</em> ([dcl.name])</u>. […]</p>
</blockquote>
<h4 id="class.static.data">[class.static.data]</h4>
<p>Change paragraph 2:</p>
<blockquote>
<p>The declaration of a non-inline static data member in its class definition is not a definition and may be of an incomplete type other than <em>cv</em> <code>void</code>. <s>The definition for a static data member that is not defined inline in the class definition shall appear in a namespace scope enclosing the member’s class definition. In the definition at namespace scope, the name of the static data member shall be qualified by its class name using the <code>::</code> operator.</s> <u>[<em>Note</em>: </u>The <em>initializer</em><s> expression</s> in the definition of a static data member is in the scope of its class ([basic.scope.class]).<u> — <em>end note</em>]</u> [<em>Example</em>:</p>
<p>[…] — <em>end example</em>]</p>
<p>[<em>Note</em>: […] — <em>end note</em>]</p>
</blockquote>
<h3 id="class.nest">[class.nest]</h3>
<p>Change paragraph 1:</p>
<blockquote>
<p>A class can be declared within another class. A class declared within another is called a <em>nested class</em>. <s>The name of a nested class is local to its enclosing class. The nested class is in the scope of its enclosing class.</s> [<em>Note</em>: See [expr.prim.id] for restrictions on the use of non-static data members and non-static member functions. — <em>end note</em>]</p>
<p>[<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 4:</p>
<blockquote>
<p><s>Like a member function, a</s><u>A</u> friend function ([class.friend]) defined within a nested class <s>is in the lexical scope of that class; it obeys the same rules for name binding as a static member function of that class, but it </s>has no special access rights to members of an enclosing class.</p>
</blockquote>
<h3 id="class.nested.type">[class.nested.type]</h3>
<p>Remove subclause, referring the stable name to [diff.basic].</p>
<h3 id="class.union.anon">[class.union.anon]</h3>
<p>Change paragraph 1:</p>
<blockquote>
<p>A union of the form</p>
<blockquote>
<p><code>union</code> <code>{</code> <em>member-specification</em> <code>}</code> <code>;</code></p>
</blockquote>
<p>is called an <em>anonymous union</em>; it defines an unnamed type and an unnamed <s>object</s><u>variable</u> of that type called an <em>anonymous union <s>object</s><u>variable</u></em>. Each <em>member-declaration</em> in the <em>member-specification</em> of an anonymous union shall either define <s>a</s><u>one or more</u> non-static data member<u>s, in which case each <em>member-declarator</em> is considered to be a declaration of the named member of the anonymous union variable,</u> or be a <em>static_assert-declaration</em>. [<em>Note</em>: Nested types, anonymous unions, and functions cannot be declared within an anonymous union. — <em>end note</em>] The names of the members of an anonymous union <u>are bound in the scope that encloses the union declaration and </u>shall be distinct from the names of any other entity in th<s>e</s><u>at</u> scope<s> in which the anonymous union is declared</s>. <s>For the purpose of name lookup, after the anonymous union definition, the members of the anonymous union are considered to have been defined in the scope in which the anonymous union is declared.</s> [<em>Example</em>:</p>
<p>[…]</p>
<p>Here <code>a</code> and <code>p</code> are used like ordinary (non-member) variables, but since they are union members they have the same address. — <em>end example</em>]</p>
</blockquote>
<h3 id="class.local">[class.local]</h3>
<p>Change paragraph 1:</p>
<blockquote>
<p>A class can be declared within a function definition; such a class is called a <em>local class</em>. <s>The name of a local class is local to its enclosing scope. The local class is in the scope of the enclosing scope, and has the same access to names outside the function as does the enclosing function.</s> [<em>Note</em>: […] — <em>end note</em>] [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<h3 id="class.derived">[class.derived]</h3>
<p>Change paragraph 2:</p>
<blockquote>
<p>A <em>class-or-decltype</em> shall denote a (possibly cv-qualified) class type that is not an incompletely defined class ([class.mem]); any cv-qualifiers are ignored. The class denoted by the <em>class-or-decltype</em> of a <em>base-specifier</em> is called a <em>direct base class</em> for the class being defined. During the lookup for <s>a base class</s><u>the</u> name<u> in the <em>type-name</em> or <em>simple-template-id</em></u>, non-type names are ignored ([basic.<s>scope.hiding</s><u>lookup</u>]). A class <code>B</code> is a base class of a class <code>D</code> if it is a direct base class of <code>D</code> or a direct base class of one of <code>D</code>’s base classes. A class is an <em>indirect base class</em> of another if it is a base class but not a direct base class. A class is said to be (directly or indirectly) <em>derived</em> from its (direct or indirect) base classes. [<em>Note</em>: See [class.access] for the meaning of <em>access-specifier</em>. — <em>end note</em>] <s>Unless redeclared in the derived class, members of a base class are also considered to be members of the derived class.</s> Members of a base class other than constructors are said to be <em>inherited</em> by the derived class<u> and are also considered to be members of it</u>. Constructors of a base class can also be inherited as described in [namespace.udecl]. <u>[<em>Note</em>: </u>Inherited members can be referred to in expressions in the same manner as other members of the derived class, unless their names are hidden or ambiguous ([class.member.lookup]). <s>[<em>Note</em>: </s>The scope resolution operator <code>::</code> ([expr.prim.id.qual]) can be used to refer to a direct or indirect base member explicitly. This allows access to a name that has been redeclared in the derived class. A derived class can itself serve as a base class subject to access control; see [class.access.base]. A pointer to a derived class can be implicitly converted to a pointer to an accessible unambiguous base class ([conv.ptr]). An lvalue of a derived class type can be bound to a reference to an accessible unambiguous base class ([dcl.init.ref]). — <em>end note</em>]</p>
</blockquote>
<h3 id="class.access">[class.access]</h3>
<p>Change paragraph 1:</p>
<blockquote>
<p>A member of a class can be</p>
<ol style="list-style-type: decimal">
<li>private; that is, it<s>s name</s> can be <s>us</s><u>nam</u>ed only by members and friends of the class in which it is declared.</li>
<li>protected; that is, it<s>s name</s> can be <s>us</s><u>nam</u>ed only by members and friends of the class in which it is declared, by classes derived from that class, and by their friends (see [class.protected]).</li>
<li>public; that is, it<s>s name</s> can be <s>us</s><u>nam</u>ed anywhere without access restriction.</li>
</ol>
<p><u>[<em>Note</em>: A constructor or destructor can be named by an expression ([basic.def.odr]) even though it has no name. — <em>end note</em>]</u></p>
</blockquote>
<p>Change paragraph 2:</p>
<blockquote>
<p>A member of a class can also access all the <s>name</s><u>member</u>s to which the class has access. A local class of a member function may access the same <s>name</s><u>member</u>s that the member function itself may access.<sup>[…]</sup></p>
</blockquote>
<p>Change paragraph 5:</p>
<blockquote>
<p>[<em>Note</em>: Access<s> to members and base classes is</s> control<s>led, not their visibility ([basic.scope.hiding]). Names of</s><u> does not prevent</u> members <s>are still visible, and</s><u>from being found by name lookup or</u> implicit conversions to base classes <s>are still</s><u>from being</u> considered<s>, when those members and base classes are inaccessible</s>. — <em>end note</em>] The interpretation of a given construct is established without regard to access control. If the interpretation established makes use of inaccessible member names or base classes, the construct is ill-formed.</p>
</blockquote>
<p>Change paragraph 8:</p>
<blockquote>
<p><s>T</s><u>Access is checked for t</u>he names in a default argument ([dcl.fct.default]) <s>are bound </s>at the point of declaration<s>, and access is checked at that point </s>rather than at any points of use of the default argument. Access checking for default arguments in function templates and in member functions of class templates is performed as described in [temp.inst].</p>
</blockquote>
<h4 id="class.friend">[class.friend]</h4>
<p>Change paragraph 2:</p>
<blockquote>
<p>Declaring a class to be a friend implies that the names of private and protected members from the class granting friendship can be accessed in the <em>base-specifier</em>⁠s and member declarations of the befriended class. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>] [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
<p><s>A class shall not be defined in a friend declaration. [<em>Example</em>:</s></p>
<p><s>[…]</s></p>
<p><s>— <em>end example</em>]</s></p>
</blockquote>
<p>Change paragraph 5:</p>
<blockquote>
<p><s>When a</s><u>[<em>Note</em>: A</u> friend declaration refers to an <s>overloaded</s><u>entity, not (all overloads of) a</u> name<s> or operator, only the function specified by the parameter types becomes a friend</s>.<u> — <em>end note</em>]</u> A member function of a class <code>X</code> can be a friend of a class <code>Y</code>. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 6:</p>
<blockquote>
<p>A function can be defined in a friend declaration of a class if and only if the class is a non-local class ([class.local])<s>,</s><u> and</u> the function name is unqualified<s>, and the function has namespace scope</s>. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 7:</p>
<blockquote>
<p>Such a function is implicitly an inline function ([dcl.inline]). <s>A</s><u>[<em>Note</em>: If a</u> friend function <u>is </u>defined <s>in</s><u>outside</u> a class<u>, it</u> is<u> not</u> in the <s>(lexical) </s>scope of the class<s> in which it is defined</s>. <s>A friend function defined outside the class is not ([basic.lookup.unqual]).</s><u>— <em>end note</em>]</u></p>
</blockquote>
<p>Replace paragraph 11, adding the example from [namespace.memdef]/3 and then retaining its example:</p>
<blockquote>
<p>[<em>Note</em>: A friend declaration never binds any names ([dcl.meaning], [dcl.type.elab]). — <em>end note</em>] [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>] [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<h4 id="class.paths">[class.paths]</h4>
<p>Change paragraph 1:</p>
<blockquote>
<p>If a <s>name</s><u>declaration</u> can be reached by several paths through a multiple inheritance graph, the access is that of the path that gives most access. [<em>Example</em>:</p>
<p>[…] — <em>end example</em>]</p>
</blockquote>
<h3 id="class.base.init">[class.base.init]</h3>
<p>Change paragraph 2:</p>
<blockquote>
<p><s>I</s><u>Lookup for an unqualified name i</u>n a <em>mem-initializer-id</em> <s>an initial unqualified <em>identifier</em> is looked up in the scope of the constructor’s class and, if not found in that scope, it is looked up in the scope containing the constructor’s definition</s><u>ignores the constructor’s function parameter scope</u>.<!-- remote --> [<em>Note</em>: If the constructor’s class contains a member with the same name as a direct or virtual base class of the class, a <em>mem-initializer-id</em> naming the member or base class and composed of a single identifier refers to the class member. A <em>mem-initializer-id</em> for the hidden base class may be specified using a qualified name. — <em>end note</em>] Unless the <em>mem-initializer-id</em> names the constructor’s class, a non-static data member of the constructor’s class, or a direct or virtual base of that class, the <em>mem-initializer</em> is ill-formed.</p>
</blockquote>
<p>Change paragraph 15:</p>
<blockquote>
<p><s>Names in t</s><u>[<em>Note</em>: T</u>he <em>expression-list</em> or <em>braced-init-list</em> of a <em>mem-initializer</em> <s>are evaluated</s><u>is</u> in the <u>function parameter </u>scope of the constructor <s>for which the <em>mem-initializer</em> is specified.</s><u>and can use <code>this</code> to refer to the object being initialized. — <em>end note</em>]</u> [<em>Example</em>:</p>
<p>[…]</p>
<p>initializes <code>X::r</code> to refer to <code>X::a</code>, initializes <code>X::b</code> with the value of the constructor parameter <code>i</code>, initializes <code>X::i</code> with the value of the constructor parameter <code>i</code>, and initializes <code>X::j</code> with the value of <code>X::i</code>; this takes place each time an object of class <code>X</code> is created. — <em>end example</em>] <s>[<em>Note</em>: Because the <em>mem-initializer</em> are evaluated in the scope of the constructor, the <code>this</code> pointer can be used in the <em>expression-list</em> of a <em>mem-initializer</em> to refer to the object being initialized. — <em>end note</em>]</s></p>
</blockquote>
<h2 id="class.free">[class.free]</h2>
<!-- TODO: /4: "looked up in the scope"; CWG255 -->

<p>Change paragraph 7:</p>
<blockquote>
<p>Access to the deallocation function is checked statically<s>. Hence</s>, even though a different one might actually be executed<s>, the statically visible deallocation function is required to be accessible</s>. [<em>Example</em>: For the call on line “// 1” above, if <code>B::operator delete()</code> had been private, the delete expression would have been ill-formed. — <em>end example</em>]</p>
</blockquote>
<h2 id="over">[over]</h2>
<p>Change paragraph 2:</p>
<blockquote>
<p>When a function <s>name </s>is <s>us</s><u>nam</u>ed in a call, which function declaration is being referenced and the validity of the call are determined by comparing the types of the arguments at the point of use with the types of the parameters in the declarations <s>that are visible at the point of use</s><u>in the overload set</u>. This function selection process is called <em>overload resolution</em> and is defined in [over.match]. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<h3 id="over.dcl">[over.dcl]</h3>
<!-- TODO: /1: function identity (overlaps with the alternate interpretation (vs. CWG1884) of [basic.link]/11) -->

<p>Remove paragraph 2.</p>
<h3 id="over.match.funcs">[over.match.funcs]</h3>
<p>Insert before paragraph 7:</p>
<blockquote>
<p>In each case where conversion functions of a class <code>S</code> are considered for initializing an object or reference of type <code>T</code>, the candidate functions include the result of a search for the <em>conversion-function-id</em> <code>operator T</code> in <code>S</code>. [<em>Note</em>: This search may find a specialization of a conversion function template ([basic.lookup]). — <em>end note</em>] Each case also defines sets of other permissible types (that are suitable for the initialization) for explicit and non-explicit conversion functions; each such conversion function that is a non-hidden member of <code>S</code> and yields a permissible type is a candidate function. If initializing an object, for any permissible type <em>cv</em> <code>U</code>, <em>cv</em> <code>U&amp;</code> and any <em>cv2</em> <code>U</code> are also permissible types. If the set of permissible types for explicit conversion functions is empty, any search results that are explicit are not candidates.</p>
</blockquote>
<p>Change paragraph 7:</p>
<blockquote>
<p>In each case where a candidate is a function template, candidate function template specializations are generated using template argument deduction ([temp.over], [temp.deduct]). If a constructor template or conversion function template has an <em>explicit-specifier</em> whose <em>constant-expression</em> is value-dependent ([temp.dep]), template argument deduction is performed first and then, if the context <s>requires a</s><u>admits only</u> candidate<u>s</u> that <s>is</s><u>are</u> not explicit and the generated specialization is explicit ([dcl.fct.spec]), it will be removed from the candidate set. Those candidates are then handled as candidate functions in the usual way.<sup>[…]</sup> A given name can refer to<u>, or a conversion can consider,</u> one or more function templates <s>and also to</s><u>as well as</u> a set of overloaded non-template functions. In such a case, the candidate functions generated from each function template are combined with the set of non-template candidate functions.</p>
</blockquote>
<h4 id="over.call.func">[over.call.func]</h4>
<p>Change paragraph 1:</p>
<blockquote>
<p>Of interest in [over.call.func] are only those function calls in which the <em>postfix-expression</em> ultimately contains a<s> name</s><u>n <em>id-expression</em></u> that denotes one or more functions that might be called. […]</p>
</blockquote>
<p>Change paragraph 2:</p>
<blockquote>
<p>In qualified function calls, the <s>name to be resolved</s><u>function</u> is <u>named by </u>an <em>id-expression</em> <s>and is </s>preceded by an <code>-&gt;</code> or <code>.</code> operator. Since the construct <code>A-&gt;B</code> is generally equivalent to <code>(*A).B</code>, the rest of [over] assumes, without loss of generality, that all member function calls have been normalized to the form that uses an object and the <code>.</code> operator. Furthermore, [over] assumes that the <em>postfix-expression</em> that is the left operand of the <code>.</code> operator has type “<em>cv</em> <code>T</code>” where <code>T</code> denotes a class.<sup>[…]</sup> <s>Under this assumption, the <em>id-expression</em> in the call is looked up as a member function of <code>T</code> following the rules for looking up names in classes ([class.member.lookup]).</s> The function declarations found by <s>that</s><u>name</u> lookup<u> ([class.member.lookup])</u> constitute the set of candidate functions. The argument list is the <em>expression-list</em> in the call augmented by the addition of the left operand of the <code>.</code> operator in the normalized member function call as the implied object argument ([over.match.funcs]).</p>
</blockquote>
<p>Change paragraph 3:</p>
<blockquote>
<p>In unqualified function calls, the <u>function is </u>name<u>d</u> <s>is not qualified </s>by<s> an <code>-&gt;</code> or <code>.</code> operator and has the more general form of</s> a <em>primary-expression</em>. <s>The name is looked up in the context of the function call following the normal rules for name lookup in expressions ([basic.lookup]).</s> The function declarations found by <s>that</s><u>name</u> lookup<u> ([basic.lookup])</u> constitute the set of candidate functions. Because of the rules for name lookup, the set of candidate functions consists (1) entirely of non-member functions or (2) entirely of member functions of some class <code>T</code>. In case (1), the argument list is the same as the <em>expression-list</em> in the call. In case (2), the argument list is the <em>expression-list</em> in the call augmented by the addition of an implied object argument as in a qualified function call. If <u>the current class is or is derived from <code>T</code> and </u>the keyword <code>this</code> ([<s>class</s><u>expr.prim</u>.this]) <s>is in scope and </s>refers to <s>class <code>T</code>, or a derived class of <code>T</code></s><u>it</u>, then the implied object argument is <code>(*this)</code>. <s>If the keyword <code>this</code> is not in scope or refers to another class, then</s><u>Otherwise,</u> a contrived object of type <code>T</code> becomes the implied object argument<s>.</s><sup>[…]</sup><u>;</u> <s>I</s><u>i</u>f<s> the argument list is augmented by a contrived object and</s> overload resolution selects <s>one of the</s><u>a</u> non-static member function<s>s of <code>T</code></s>, the call is ill-formed.</p>
</blockquote>
<h4 id="over.call.object">[over.call.object]</h4>
<p>Change paragraph 1:</p>
<blockquote>
<p>If the <em>postfix-expression</em> <code>E</code> in the function call syntax evaluates to a class object of type “<em>cv</em> <code>T</code>”, then the set of candidate functions includes at least the function call operators of <code>T</code>. The function call operators of <code>T</code> are <s>obtained by ordinary lookup</s><u>the results</u> of <u>a search for </u>the name <code>operator()</code> in the <s>context</s><u>scope</u> of <s><code>(E).operator()</code></s><u><code>T</code></u>.</p>
</blockquote>
<h4 id="over.match.oper">[over.match.oper]</h4>
<p>Change bullet (3.2):</p>
<blockquote>
<p><s>T</s><u>For the operators <code>=</code>, <code>[]</code>, or <code>-&gt;</code>, t</u>he set of non-member candidates is<u> empty; otherwise, it includes</u> the result of <s>the </s>unqualified lookup <s>of</s><u>for</u> <code>operator@</code> <s>in the context of the expression according to the usual rules for name lookup in unqualified</s><u>in the rewritten</u> function call<s>s</s> ([basic.lookup.argdep])<s> except that</s><u>, ignoring</u> all member functions<s> are ignored</s>. However, if no operand has a class type, only those non-member functions in the lookup set that have a first parameter of type <code>T1</code> or “reference to <em>cv</em> <code>T1</code>”, when <code>T1</code> is an enumeration type, or (if there is a right operand) a second parameter of type <code>T2</code> or “reference to <em>cv</em> <code>T2</code>”, when <code>T2</code> is an enumeration type, are candidate functions.</p>
</blockquote>
<h4 id="over.match.copy">[over.match.copy]</h4>
<p>Change bullet (1.2):</p>
<blockquote>
<p>When the type of the initializer expression is a class type “<em>cv</em> <code>S</code>”, <s>the non-explicit </s>conversion functions<s> of <code>S</code> and its base classes</s> are considered. <u>The permissible types for non-explicit conversion functions are <code>T</code> and any class derived from <code>T</code>.</u> When initializing a temporary object ([class.mem]) to be bound to the first parameter of a constructor where the parameter is of type “reference to possibly <em>cv</em>-qualified <code>T</code>” and the constructor is called with a single argument in the context of direct-initialization of an object of type “<em>cv2</em> <code>T</code>”, <u>the permissible types for </u>explicit conversion functions are <s>also considered</s><u>the same; otherwise there are none</u>. <s>Those that are not hidden within <code>S</code> and yield a type whose cv-unqualified version is the same type as <code>T</code> or is a derived class thereof are candidate functions. A call to a conversion function returning “reference to <code>X</code>” is a glvalue of type <code>X</code>, and such a conversion function is therefore considered to yield <code>X</code> for this process of selecting candidate functions.</s></p>
</blockquote>
<h4 id="over.match.conv">[over.match.conv]</h4>
<p>Change paragraph 1:</p>
<blockquote>
<p>Under the conditions specified in [dcl.init], as part of an initialization of an object of non-class type, a conversion function can be invoked to convert an initializer expression of class type to the type of the object being initialized. Overload resolution is used to select the conversion function to be invoked. Assuming that “<em>cv<s>1</s></em> <code>T</code>” is the type of the object being initialized<s>, and “<em>cv</em> <code>S</code>” is the type of the initializer expression, with <code>S</code> a class type</s>, the candidate functions are selected as follows:</p>
<ol style="list-style-type: decimal">
<li>The <s>conversion functions of <code>S</code> and its base classes are considered. Those</s><u>permissible types for</u> non-explicit conversion functions <s>that </s>are <s>not hidden within <code>S</code> and yield type <code>T</code> or a type</s><u>those</u> that can be converted to type <code>T</code> via a standard conversion sequence ([over.ics.scs])<s> are candidate functions</s>. For direct-initialization, <s>those</s><u>the permissible types for</u> explicit conversion functions <s>that </s>are <s>not hidden within <code>S</code> and yield type <code>T</code> or a type</s><u>those</u> that can be converted to type <code>T</code> with a <u>(possibly trivial) </u>qualification conversion ([conv.qual])<s> are also candidate functions</s><u>; otherwise there are none</u>. <s>Conversion functions that return a cv-qualified type are considered to yield the cv-unqualified version of that type for this process of selecting candidate functions. A call to a conversion function returning “reference to <code>X</code>” is a glvalue of type <code>X</code>, and such a conversion function is therefore considered to yield <code>X</code> for this process of selecting candidate functions.</s></li>
</ol>
</blockquote>
<h4 id="over.match.ref">[over.match.ref]</h4>
<p>Change paragraph 1:</p>
<blockquote>
<p>Under the conditions specified in [dcl.init.ref], a reference can be bound directly to the result of applying a conversion function to an initializer expression. Overload resolution is used to select the conversion function to be invoked. Assuming that “reference to <em>cv1</em> <code>T</code>” is the type of the reference being initialized<s>, and “<em>cv</em> <code>S</code>” is the type of the initializer expression, with <code>S</code> a class type</s>, the candidate functions are selected as follows:</p>
<ol style="list-style-type: decimal">
<li><s>The conversion functions of <code>S</code> and its base classes are considered. Those non-explicit conversion functions that are not hidden within <code>S</code> and yield</s><u>Let <em>R</em> be a set of</u> type<u>s including</u> “lvalue reference to <em>cv2</em> <code>T2</code>” (when initializing an lvalue reference or an rvalue reference to function) <s>or</s><u>and</u> “<em>cv2</em> <code>T2</code>” <s>or</s><u>and</u> “rvalue reference to <em>cv2</em> <code>T2</code>” (when initializing an rvalue reference or an lvalue reference to function)<s>,</s><u> for any <code>T2</code>. The permissible types for non-explicit conversion functions are the members of <em>R</em></u> where “<em>cv1</em> <code>T</code>” is reference-compatible ([dcl.init.ref]) with “<em>cv2</em> <code>T2</code>”<s>, are candidate functions</s>. For direct-initialization, <s>those</s><u>the permissible types for</u> explicit conversion functions <s>that </s>are <s>not hidden within <code>S</code> and yield type “lvalue reference to <em>cv2</em> <code>T2</code>” (when initializing an lvalue reference or an rvalue reference to function) or “rvalue reference to <em>cv2</em> <code>T2</code>” (when initializing an rvalue reference or an lvalue reference to function),</s><u>the members of <em>R</em></u> where <code>T2</code> <s>is the same type as <code>T</code> or </s>can be converted to type <code>T</code> with a <u>(possibly trivial) </u>qualification conversion ([conv.qual])<s>, are also candidate functions</s><u>; otherwise there are none</u>.</li>
</ol>
</blockquote>
<h4 id="over.match.best">[over.match.best]</h4>
<p>Change paragraph 4:</p>
<blockquote>
<p>If the best viable function resolves to a function for which multiple declarations were found, and if <s>at least</s><u>any</u> two of these declarations <s>— or the declarations they refer to in the case of <em>using-declaration</em>⁠s — </s>specify a default argument<u> for the same parameter</u> that made the function viable, the program is ill-formed. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<h3 id="over.over">[over.over]</h3>
<p>Change paragraph 1:</p>
<blockquote>
<p>A<s> use of a</s><u>n <em>id-expression</em> that names a</u>n overload<s>ed function name</s><u> set</u> without arguments is resolved in certain contexts to a function, a pointer to function or a pointer to member function for a specific function from the overload set. A function template name is considered to name a set of overloaded functions in such contexts. A function with type <code>F</code> is selected for the function type <code>FT</code> of the target type required in the context if <code>F</code> (after possibly applying the function pointer conversion ([conv.fctptr])) is identical to <code>FT</code>. [<em>Note</em>: That is, the class of which the function is a member is ignored when matching a pointer-to-member-function type. — <em>end note</em>] The target can be</p>
<ol style="list-style-type: decimal">
<li>an object or reference being initialized ([dcl.init], [dcl.init.ref], [dcl.init.list]),</li>
<li>the left side of an assignment ([expr.ass]),</li>
<li>a parameter of a function ([expr.call]),</li>
<li>a parameter of a user-defined operator ([over.oper]),</li>
<li>the return value of a function, operator function, or conversion ([stmt.return]),</li>
<li>an explicit type conversion ([expr.type.conv], [expr.static.cast], [expr.cast]), or</li>
<li>a non-type <em>template-parameter</em> ([temp.arg.nontype]).</li>
</ol>
<p>The <s>overloaded function name</s><u><em>id-expression</em></u> can be preceded by the <code>&amp;</code> operator. An <u><em>id-expression</em> that names an </u>overload<s>ed function name</s><u> set</u> shall not be used without arguments in contexts other than those listed.<!-- TODO: universal overload resolution would say that all other contexts must have exactly one non-discarded candidate --> [<em>Note</em>: Any redundant set of parentheses surrounding the overloaded function name is ignored ([expr.prim.paren]). — <em>end note</em>]</p>
</blockquote>
<p>Change paragraph 2:</p>
<blockquote>
<p>If the <u><em>id-expression</em> is a <em>template-id</em> or </u>name<s> i</s>s a function template, template argument deduction is done ([temp.deduct.funcaddr]), and if the argument deduction succeeds, the resulting template argument list is used to generate a single function template specialization, which is added to the set of overloaded functions considered. [<em>Note</em>: […] — <em>end note</em>]</p>
</blockquote>
<p>Change paragraph 3:</p>
<blockquote>
<p>Non-member functions and static member functions match targets of function pointer type or reference to function type. Non-static member functions match targets of pointer-to-member-function type. <u>[<em>Note</em>: </u>If a non-static member function is selected, the <s>reference to the overloaded function name is required to have the form of</s><u>result can be used only to form</u> a pointer to member<s> as described in</s> <u>(</u>[expr.unary.op]<u>)</u>.<u> — <em>end note</em>]</u></p>
</blockquote>
<h3 id="over.oper">[over.oper]</h3>
<h4 id="over.unary">[over.unary]</h4>
<p>Change paragraph 2:</p>
<blockquote>
<p><u>[<em>Note</em>: </u>The unary and binary forms of the same operator <s>are considered to </s>have the same name. <s>[<em>Note</em>: </s>Consequently, a unary operator can hide a binary operator from an enclosing scope, and vice versa. — <em>end note</em>]</p>
</blockquote>
<h4 id="over.literal">[over.literal]</h4>
<p>Change paragraph 2:</p>
<blockquote>
<p>A declaration whose <em>declarator-id</em> is a <em>literal-operator-id</em> shall <s>be a </s>declar<s>ation of</s><u>e</u> a <s>namespace-scope </s>function or function template<u> that belongs to a namespace</u> (it could be a friend function ([class.friend]))<s>,</s><u> or</u> an explicit instantiation or specialization of a function template<s>, or a <em>using-declaration</em> ([namespace.udecl])</s>. A function declared with a <em>literal-operator-id</em> is a <em>literal operator</em>. A function template declared with a <em>literal-operator-id</em> is a <em>literal operator template</em>.</p>
</blockquote>
<h2 id="temp">[temp]</h2>
<p>Change paragraph 4:</p>
<blockquote>
<p>A <em>template-declaration</em> can appear only as a namespace scope or class scope declaration. Its <em>declaration</em> shall not be an <em>export-declaration</em>. In a function template declaration, the last component of the <em>declarator-id</em> shall <s>not </s>be a <s><em>template-id</em></s><u>name</u>. [<em>Note</em>: <s>That last component may be an <em>identifier</em>, an <em>operator-function-id</em>, a <em>conversion-function-id</em>, or a <em>literal-operator-id</em>.</s> In a class template declaration, if the <s>class name</s><u><em>class-name</em></u> is a <em>simple-template-id</em>, the declaration declares a class template partial specialization ([temp.class.spec]). — <em>end note</em>]</p>
</blockquote>
<p>Change paragraph 8:</p>
<blockquote>
<p><u>[<em>Note</em>: </u>A <s>class </s>template shall not have the same name as any other <s>template, class, function, variable, enumeration, enumerator, namespace, or type</s><u>name bound</u> in the same scope ([basic.scope]), except <s>as specified in [temp.class.spec]. Except </s>that a function template can be overloaded <s>either by</s><u>with</u> non-template functions ([dcl.fct]) <s>with the same name or by other</s><u>and/or</u> function templates<s> with the same name</s> ([temp.over])<s>, a template name declared in namespace scope or in class scope shall be unique in that scope</s>. <u>Specializations, including partial specializations ([temp.class.spec]), do not bind names. — <em>end note</em>]</u></p>
</blockquote>
<h3 id="temp.param">[temp.param]</h3>
<p>Change paragraph 14:</p>
<blockquote>
<p>A <em>template-parameter</em> shall not be given default arguments by two different declarations <s>in the same scope</s><u>if one is reachable from the other</u>. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<h3 id="temp.names">[temp.names]</h3>
<p>Remove the note in paragraph 1.</p>
<p>Change paragraph 2:</p>
<blockquote>
<p><s>For a <em>template-name</em> to be explicitly qualified by the template arguments, the name must be considered to refer to a template. [<em>Note</em>: Whether a name actually refers to a template cannot be known in some cases until after argument dependent lookup is done ([basic.lookup.argdep]). — <em>end note</em>]</s> A <s>name</s><u><code>&lt;</code></u> is <s>considered to refer to</s><u>interpreted as the delimiter of</u> a <s>template</s><u><em>template-argument-list</em></u> if<u> it follows a name, other than a <em>conversion-function-id</em>,</u></p>
<ol style="list-style-type: decimal">
<li><u>that follows the keyword <code>template</code> after a <em>nested-name-specifier</em> or in a class member access expression, or</u></li>
<li><u>for which </u>name lookup finds <u>the injected-class-name of a class template or finds </u>a<s> <em>template-name</em> or an overload set that contains a function template.</s><u>ny declaration of a template that, unless the name is in a closed context of a class or class template ([class.mem]), precedes the name, or</u></li>
<li><s>A name is also considered to refer to a template if it</s><u>that</u> is an <s><em>unqualified-id</em></s><u>unqualified name</u> followed by a <code>&lt;</code> and name lookup either finds one or more functions or finds nothing<s>.</s><u>, or</u></li>
<li><u>that is an unqualified or terminal name in a <em>using-declarator</em> ([namespace.udecl]), a <em>declarator-id</em> ([dcl.meaning]), or a type-only context ([temp.res]).</u></li>
</ol>
<p><u>[<em>Note</em>: If the name is an <em>identifier</em>, it is then interpreted as a <em>template-name</em>. The keyword <code>template</code> is used to indicate that a qualified dependent name ([temp.dep.type]) denotes a template where an expression might appear or that a name in a class member access ([expr.ref]) is not dependent because it is part of a <em>nested-name-specifier</em>. — <em>end note</em>] If a <em>simple-template-id</em> results and is followed by a <code>::</code>, the name is looked up as part of a <em>nested-name-specifier</em>, discarding any previous lookup result.</u></p>
</blockquote>
<p>Move the example from paragraph 4 to the end of paragraph 2.</p>
<p>Change paragraph 3:</p>
<blockquote>
<p><s>When a name is considered to be a <em>template-name</em>, and it is followed by a <code>&lt;</code>, the <code>&lt;</code> is always taken as the delimiter of a <em>template-argument-list</em> and never as the less-than operator.</s> When parsing a <em>template-argument-list</em>, the first non-nested <code>&gt;</code><sup>[…]</sup> is taken as the ending delimiter rather than a greater-than operator. Similarly, the first non-nested <code>&gt;&gt;</code> is treated as two consecutive but distinct <code>&gt;</code> tokens, the first of which is taken as the end of the <em>template-argument-list</em> and completes the <em>template-id</em>. [<em>Note</em>: The second <code>&gt;</code> token produced by this replacement rule may terminate an enclosing <em>template-id</em> construct or it may be part of a different construct (e.g., a cast).— <em>end note</em>] [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 4:</p>
<blockquote>
<p>The keyword <code>template</code> <s>is said to</s><u>shall not</u> appear <s>at the top level</s><u>directly</u> in a <em>qualified-id</em> <s>if it appears outside of a <em>template-argument-list</em> or <em>decltype-specifier</em>. In a <em>qualified-id</em></s> of a <em>declarator-id</em> or in a <em>qualified-id</em> formed by a <em>class-head-name</em> ([class]) or <em>enum-head-name</em> ([dcl.enum]), <s>the keyword <code>template</code> shall not appear at the top level</s><u>nor directly in the <em>nested-name-specifier</em> of such a <em>qualified-id</em> or (recursively) of such a <em>nested-name-specifier</em></u>.<!-- TODO: reword: the first "directly", "recursively" --> <s>In a <em>qualified-id</em> used as the name in a <em>typename-specifier</em> ([temp.res]), <em>elaborated-type-specifier</em> ([dcl.type.elab]), <em>using-declaration</em> ([namespace.udecl]), or <em>class-or-decltype</em> ([class.derived]), an optional keyword <code>template</code> appearing at the top level is ignored. In these contexts, a <code>&lt;</code> token is always assumed to introduce a <em>template-argument-list</em>. In all other contexts, when naming a template specialization of a member of an unknown specialization ([temp.dep.type]), the member template name shall be prefixed by the keyword <code>template</code>. [<em>Example</em>:</s></p>
<p><s>[…]</s></p>
<p><s>— <em>end example</em>]</s></p>
</blockquote>
<p>Change paragraph 5:</p>
<blockquote>
<p>A name prefixed by the keyword <code>template</code> shall be <s>a <em>template-id</em></s><u>followed by a template argument list</u> or <s>the name shall </s>refer to a class template or an alias template. <u>The latter case is deprecated ([depr.template.template]). The keyword <code>template</code> shall not appear immediately before a <code>~</code> token (as to name a destructor).</u> [<em>Note</em>: The keyword <code>template</code> may not be applied to non-template members of class templates. — <em>end note</em>][<em>Note</em>: As is the case with the <code>typename</code> prefix, the <code>template</code> prefix is allowed <s>in cases where it is not strictly necessary; i.e., when the <em>nested-name-specifier</em> or the expression on the left of the <code>-&gt;</code> or <code>.</code> is not dependent on a <em>template-parameter</em>, or the use does not appear in the scope of</s><u>even when lookup for the name would already find</u> a template. — <em>end note</em>] [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 8:</p>
<blockquote>
<p>When the <em>template-name</em> of a <em>simple-template-id</em> names a constrained non-function template or a constrained template <em>template-parameter</em><s>, but not a member template that is a member of an unknown specialization ([temp.res])</s>, and all <em>template-argument</em>⁠s in the <em>simple-template-id</em> are non-dependent ([temp.dep.temp]), the associated constraints ([temp.constr.decl]) of the constrained template shall be satisfied ([temp.constr.constr]). [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<h3 id="temp.arg">[temp.arg]</h3>
<p>Change paragraph 3:</p>
<blockquote>
<p><s>The n</s><u>N</u>ame<u>s</u> <s>of</s><u>used in</u> a <em>template-argument</em> <s>shall be accessible at the point where it is used as a <em>template-argument</em></s><u>are subject to access control where they appear</u>. [<em>Note</em>: <s>If the name of the <em>template-argument</em> is accessible at the point where it is used as a <em>template-argument</em>, there is no further access restriction in the resulting instantiation where the corresponding</s><u>Since a</u> <em>template-parameter</em><s> name</s> is <s>used</s><u>not a class member, no access control applies</u>. — <em>end note</em>] [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>] For a <em>template-argument</em> that is a class type or a class template, the template definition has no special access rights to the members of the <em>template-argument</em>. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 7:</p>
<blockquote>
<p>When name lookup for the name in a <em>template-id</em> finds an overload set, both non-template functions in the overload set and function templates in the overload set for which the <em>template-argument</em>⁠s do not match the <em>template-parameter</em>⁠s are ignored. <u>[<em>Note</em>: </u>If none of the function templates have matching <em>template-parameter</em>⁠s, the program is ill-formed.<u> — <em>end note</em>]</u></p>
</blockquote>
<h4 id="temp.arg.template">[temp.arg.template]</h4>
<p>Change paragraph 2:</p>
<blockquote>
<p>Any partial specializations ([temp.class.spec]) associated with the primary class template or primary variable template are considered when a specialization based on the template <em>template-parameter</em> is instantiated. If a specialization is not <s>visible at</s><u>reachable from</u> the point of instantiation, and it would have been selected had it been visible, the program is ill-formed, no diagnostic required. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<h3 id="temp.decls">[temp.decls]</h3>
<h4 id="temp.mem">[temp.mem]</h4>
<p>Remove paragraph 6.</p>
<h4 id="temp.friend">[temp.friend]</h4>
<p>Change paragraph 1:</p>
<blockquote>
<p>A friend of a class or class template can be a function template or class template, a specialization of a function template or class template, or a non-template function or class. For a friend function declaration that is not a template declaration:</p>
<ol style="list-style-type: decimal">
<li>if the <s>name of the friend</s><u><em>unqualified-id</em> in the <em>declarator-id</em></u> is a <s>qualified or unqualified </s><em>template-id</em>, the friend declaration refers to a specialization of a function template, otherwise,</li>
<li>if the <s>name of the friend</s><u><em>declarator-id</em></u> is a <em>qualified-id</em> and a matching non-template function is found in the specified class or namespace, the friend declaration refers to that function, otherwise,</li>
<li>if the <s>name of the friend</s><u><em>declarator-id</em></u> is a <em>qualified-id</em> and a matching function template is found in the specified class or namespace, the friend declaration refers to the deduced specialization of that function template ([temp.deduct.decl]), otherwise,</li>
<li>the <s>name</s><u><em>declarator-id</em></u> shall be an <em>unqualified-id</em> that declares (or redeclares) a non-template function.</li>
</ol>
<p>[<em>Example</em>:</p>
<p>[…] — <em>end example</em>]</p>
</blockquote>
<h4 id="temp.class.spec">[temp.class.spec]</h4>
<p>Change paragraph 1:</p>
<blockquote>
<p>A <em>primary class template</em> declaration is one in which the <s>class template name</s><u><em>class-name</em></u> is an identifier. A template declaration in which the <s>class template name</s><u><em>class-name</em></u> is a <em>simple-template-id</em> is a <em>partial specialization</em> of the class template named in the <em>simple-template-id</em>. A partial specialization of a class template provides an alternative definition of the template that is used instead of the primary definition when the arguments in a specialization match those given in the partial specialization ([temp.class.spec.match]). <s>T</s><u>A declaration of t</u>he primary template shall <s>be declared before</s><u>precede</u> any specialization<s>s</s> of that template. A partial specialization shall <s>be declared before the first</s><u>be reachable from any</u> use of a class template specialization that would make use of the partial specialization as the result of an implicit or explicit instantiation<s> in every translation unit in which such a use occurs</s>; no diagnostic is required.</p>
</blockquote>
<p>Change paragraph 7:</p>
<blockquote>
<p>Partial specialization declarations <s>themselves are not found by name lookup</s><u>do not introduce a name</u>. <s>Rather</s><u>Instead</u>, when the primary template name is used, any <s>previously-declared</s><u>reachable</u> partial specializations of the primary template are also considered. One consequence is that a <em>using-declaration</em> which refers to a class template does not restrict the set of partial specializations which may be found through the <em>using-declaration</em>. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Insert before paragraph 8:</p>
<blockquote>
<p>A specialization of a class template partial specialization that has been declared but not defined is an incomplete type ([basic.types]).</p>
</blockquote>
<h4 id="temp.over.link">[temp.over.link]</h4>
<p>Change paragraph 5:</p>
<blockquote>
<p>Two expressions involving template parameters are considered <em>equivalent</em> if two function definitions containing the expressions would satisfy the one-definition rule ([basic.def.odr]), except that the tokens used to name the template parameters may differ as long as a token used to name a template parameter in one expression is replaced by another token that names the same template parameter in the other expression. Two <em>lambda-expression</em>⁠s are never considered equivalent. [<em>Note</em>: The intent is to avoid <em>lambda-expression</em>⁠s appearing in the signature of a function template with external linkage. — <em>end note</em>] For determining whether two dependent names ([temp.dep]) are equivalent, only the name itself is considered, not the result of name lookup<s> in the context of the template</s>. <u>[<em>Note</em>: </u>If <s>multiple declarations of the same function template differ in the result of this</s><u>such a dependent</u> name <s>lookup</s><u>is unqualified</u>, <s>the result for</s><u>it is looked up from</u> the first declaration <s>is used</s><u>of the function template ([temp.dep.candidate])</u>.<u> — <em>end note</em>]</u> [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>] Two expressions involving template parameters that are not equivalent are <em>functionally equivalent</em> if, for any given set of template arguments, the evaluation of the expression results in the same value.</p>
</blockquote>
<h3 id="temp.res">[temp.res]</h3>
<p>Replace paragraph 1:</p>
<blockquote>
<p>A name that appears in a template declaration is looked up from where it appears in the first declaration of the template that contains it. A <em>dependent name</em> is looked up for each specialization (after substitution) because the lookup depends on a template parameter, as described in [temp.dep]. [<em>Note</em>: Uses of other names might be type-dependent or value-dependent ([temp.dep.expr], [temp.dep.constexpr]). A <em>using-declarator</em> is never dependent in a specialization and is therefore replaced during lookup for a dependent name ([basic.lookup]). — <em>end note</em>] [<em>Example</em>:</p>
<pre class="sourceCode cpp"><code class="sourceCode cpp"><span class="kw">struct</span> A {<span class="kw">operator</span> <span class="dt">int</span>();};
<span class="kw">template</span>&lt;<span class="kw">class</span> B,<span class="kw">class</span> T&gt;
<span class="kw">struct</span> D : B {
  T get() {<span class="kw">return</span> <span class="kw">operator</span> T();}     <span class="co">// conversion-function-id is dependent</span>
};
<span class="dt">int</span> f(D&lt;A,<span class="dt">int</span>&gt; d) {<span class="kw">return</span> d.get();}  <span class="co">// OK: lookup finds A::operator int</span></code></pre>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Move the example from paragraph 10 and the second example from [temp.dep]/4 to the end of paragraph 1.</p>
<p>Replace paragraph 2 (but not the grammar following it):</p>
<blockquote>
<p>If the validity or meaning of the program would be changed by considering a default argument or default template argument introduced in a declaration that is reachable from the point of instantiation of a specialization ([temp.point]) but is not found by lookup for the specialization, the program is ill-formed, no diagnostic required.</p>
</blockquote>
<p>Change paragraph 3:</p>
<blockquote>
<p>A <em>typename-specifier</em> denotes the type or class template denoted by the <em>simple-type-specifier</em> ([dcl.type.simple]) formed by omitting the keyword <code>typename</code>. <u>[<em>Note</em>: </u>The usual qualified name lookup ([basic.lookup.qual]) <s>is used to find the <em>qualified-id</em></s><u>applies</u> even in the presence of <code>typename</code>.<u> — <em>end note</em>]</u> [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Replace paragraph 4:</p>
<blockquote>
<p>A name <em>appears as a type</em> in a construct if it is the construct or appears in it outside of any enclosed expression or template argument.</p>
</blockquote>
<p>Change paragraph 5:</p>
<blockquote>
<p>A <s><em>qualified-id</em></s><u>qualified or unqualified name</u> is <s>assumed</s><u>said</u> to <s>name</s><u>be in</u> a type<u>-only context</u> if</p>
<ol style="list-style-type: decimal">
<li><u>it appears as a type in a <em>typename-specifier</em>, <em>nested-name-specifier</em>, <em>elaborated-type-specifier</em>, or <em>class-or-decltype</em>,</u></li>
<li><u>it appears as a type in a <em>new-type-id</em>, <em>defining-type-id</em>, or <em>conversion-type-id</em>,</u></li>
<li>it <s>is a qualified name in a type-id-only context (see below)</s><u>appears as a type in a <em>type-id</em> that is a <em>trailing-return-type</em>, the default argument of a <em>type-parameter</em>, or the <em>type-id</em> of a <code>static_cast</code>, <code>const_cast</code>, <code>reinterpret_cast</code>, or <code>dynamic_cast</code></u>, or</li>
<li>it<u>, or a <em>template-id</em> of which it is the name,</u> is a <em>decl-specifier</em> of the <em>decl-specifier-seq</em> of a
<ol style="list-style-type: decimal">
<li><em>simple-declaration</em> or a <em>function-definition</em> in namespace scope,</li>
<li><em>member-declaration</em>,</li>
<li><em>parameter-declaration</em> in a <em>member-declaration</em><sup>[…]</sup>, unless that <em>parameter-declaration</em> appears in a default argument,</li>
<li><em>parameter-declaration</em> in a <em>declarator</em> of a function or function template declaration whose <em>declarator-id</em> is qualified, unless that <em>parameter-declaration</em> appears in a default argument,</li>
<li><em>parameter-declaration</em> in a <em>lambda-declarator</em>, unless that <em>parameter-declaration</em> appears in a default argument, or</li>
<li><em>parameter-declaration</em> of a (non-type) <em>template-parameter</em>.</li>
</ol></li>
</ol>
<p><s>A qualified name is said to be in a <em>type-id-only context</em> if it appears in a <em>type-id</em>, <em>new-type-id</em>, or <em>defining-type-id</em> and the smallest enclosing <em>type-id</em>, <em>new-type-id</em>, or <em>defining-type-id</em> is a <em>new-type-id</em>, <em>defining-type-id</em>, <em>trailing-return-type</em>, default argument of a <em>type-parameter</em> of a template, or <em>type-id</em> of a <code>static_cast</code>, <code>const_cast</code>, <code>reinterpret_cast</code>, or <code>dynamic_cast</code>.</s> [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 6:</p>
<blockquote>
<p>A <s><em>qualified-id</em> that refers to a member of an unknown specialization, that is not prefixed by <code>typename</code>, and</s><u>qualified dependent name</u> that is not <s>otherwise assumed to name</s><u>in</u> a type<u>-only context</u> (see above) <s>denotes</s><u>is interpreted as</u> a <s>non-</s><u><em>qualified-id</em>, not a </u>type. <u>A name that refers to a dependent <em>using-declarator</em> is interpreted as a <em>typedef-name</em> if the <em>using-declarator</em> uses the keyword <code>typename</code> and as an <em>unqualified-id</em> otherwise.</u> [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Remove paragraphs 7, 9, and 10 (whose example is moved to paragraph 1).</p>
<h4 id="temp.local">[temp.local]</h4>
<p>Change paragraph 3:</p>
<blockquote>
<p>The injected-class-name of a class template or class template specialization can be used as either a <em>template-name</em> or a <em>type-name</em> wherever it is <s>in scope</s><u>named</u>. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 6:</p>
<blockquote>
<p><s>A</s><u>The name of a</u> <em>template-parameter</em> shall not be <s>re</s>declared <s>within its</s><u>by a subsequent declaration contained by the</u> scope <s>(including nested scopes)</s><u>to which the <em>template-parameter</em> belongs</u>. <s>A <em>template-parameter</em> shall not have the same name as the template name.</s> [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 7:</p>
<blockquote>
<s>In the definition of a member</s><u>Unqualified name lookup considers the template parameter scope of a <em>template-declaration</em> before any scope that contains the template declared (even if it does not contain the <em>template-parameter-list</em>).<!-- non-nested, remote --> [<em>Note</em>: The scope</u> of a class template<s> that appears outside of the class template definition, the name of a member of the class template hides the name of a <em>template-parameter</em> of any enclosing class templates (but not a <em>template-parameter</em> of the member if the member is a class or function template)</s><u>, including its non-dependent base classes ([temp.dep.type], [class.member.lookup]), is searched before its template parameter scope</u>.<u> — <em>end note</em>]</u> [<em>Example</em>:
<pre class="cpp">
<u>struct B { };
namespace N {
  typedef void V;
  </u>template&lt;class T&gt; struct A <u>: B </u>{
<s>  struct B { /* ... */ };
</s><u>  </u>  typedef void C;
<u>  </u>  void f();
<u>  </u>  template&lt;class U&gt; void g(U);
<u>  </u>};
<u>}
</u>
template&lt;class <s>B</s><u>V</u>&gt; void <u>N::</u>A&lt;<s>B</s><u>V</u>&gt;::f() {
  <s>B</s><u>V</u> <s>b</s><u>v</u>;              // <s>A's B, not</s><u>V is</u> the template parameter<u>, not N::V</u>
}

template&lt;class B&gt; template&lt;class C&gt; void <u>N::</u>A&lt;B&gt;::g(C) {
  B b;              // <s>A's B</s><u>the base class</u>, not the template parameter
  C c;              // the template parameter C, not A's C
}
</pre>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Remove paragraphs 8 and 9 (whose examples are merged into the above).</p>
<h4 id="temp.dep">[temp.dep]</h4>
<p>Change paragraph 2:</p>
<blockquote>
<p><s>I</s><u>The name in an <em>unqualified-id</em> is dependent if it is a <em>conversion-function-id</em> whose <em>conversion-type-id</em> is dependent or the <em>unqualified-id</em> is the <em>postfix-expression</em> i</u>n an expression of the form:</p>
<blockquote>
<p><em>postfix-expression</em> <code>(</code> <em>expression-list</em><sub><em>opt</em></sub> <code>)</code></p>
</blockquote>
<p><s>where the <em>postfix-expression</em> is an <em>unqualified-id</em>, the <em>unqualified-id</em> denotes a <em>dependent name</em> if</s><u>including when finding non-member candidates for an operator ([over.match.oper]), and</u></p>
<ol style="list-style-type: decimal">
<li>any of the expressions in the <em>expression-list</em> is a pack expansion ([temp.variadic]),</li>
<li>any of the expressions or <em>braced-init-list</em>⁠s in the <em>expression-list</em> is type-dependent ([temp.dep.expr]), or</li>
<li>the <em>unqualified-id</em> is a <em>template-id</em> in which any of the template arguments depends on a template parameter.</li>
</ol>
<p><s>If an operand of an operator is a type-dependent expression, the operator also denotes a dependent name.</s> [<em>Note</em>: Such names <s>are unbound and </s>are looked up <u>only </u>at the point of the template instantiation ([temp.point]) in both the context of the template definition and the context of the point of instantiation ([temp.dep.candidate]). — <em>end note</em>]</p>
</blockquote>
<p>Remove paragraph 4.</p>
<h5 id="temp.dep.type">[temp.dep.type]</h5>
<p>Change paragraph 1:</p>
<blockquote>
<p>A name<u> or <em>template-id</em></u> refers to the <em>current instantiation</em> if it is</p>
<p>[…]</p>
</blockquote>
<p>Change paragraph 5:</p>
<blockquote>
<p>A <u>qualified ([basic.lookup.qual]) or unqualified </u>name is a <em>member of the current instantiation</em> if<s> it is</s></p>
<ol style="list-style-type: decimal">
<li><u>its lookup context, if it is a qualified name, is the current instantiation, and</u></li>
<li><s>An unqualified name that, when looked up, refers to at least one</s><u>lookup for it (or its terminal name) finds any (perhaps inherited)</u> member of a class that is the current instantiation<s> or a non-dependent base class thereof</s>. <s>[<em>Note</em>: This can only occur when looking up a name in a scope enclosed by the definition of a class template. — <em>end note</em>]</s></li>
<li><s>A <em>qualified-id</em> in which the <em>nested-name-specifier</em> refers to the current instantiation and that, when looked up, refers to at least one member of a class that is the current instantiation or a non-dependent base class thereof. [<em>Note</em>: If no such member is found, and the current instantiation has any dependent base classes, then the <em>qualified-id</em> is a member of an unknown specialization; see below. — <em>end note</em>]</s></li>
<li><s>An <em>id-expression</em> denoting the member in a class member access expression ([expr.ref]) for which the type of the object expression is the current instantiation, and the <em>id-expression</em>, when looked up ([basic.lookup.classref]), refers to at least one member of a class that is the current instantiation or a non-dependent base class thereof. [<em>Note</em>: If no such member is found, and the current instantiation has any dependent base classes, then the <em>id-expression</em> is a member of an unknown specialization; see below. — <em>end note</em>]</s></li>
</ol>
<p>[<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
<p>A <u>qualified or unqualified </u>name is a <em>dependent member of the current instantiation</em> if it is a member of the current instantiation that<s>, when looked up, refers to</s><u> denotes</u> at least one <u>direct </u>member of a class that is the current instantiation.</p>
</blockquote>
<p>Change paragraph 6:</p>
<blockquote>
<p>A <u>qualified </u>name<u> ([basic.lookup.qual])</u> is <s>a <em>member of an unknown specialization</em></s><u>dependent</u> if it is<u> not a member-qualified name that is a <em>nested-name-specifier</em> and</u></p>
<ol style="list-style-type: decimal">
<li><u>its terminal name is a <em>conversion-function-id</em> whose <em>conversion-type-id</em> is dependent, or</u></li>
<li><s>A <em>qualified-id</em> in which the <em>nested-name-specifier</em> names</s><u>its lookup context</u> is <s>a </s>dependent <s>type that</s><u>and</u> is not the current instantiation<s>.</s><u>, or</u></li>
<li><s>A <em>qualified-id</em> in which the <em>nested-name-specifier</em> refers to</s><u>its lookup context is</u> the current instantiation<s>, the current instantiation</s><u> and</u> has at least one dependent base class, and <s>name </s>lookup <s>of</s><u>for the terminal name of</u> the <s><em>qualified-id</em></s><u>qualified name</u> <s>does not </s>find<s> any member of a class that is the current instantiation or a non-dependent base class thereof</s><u>s nothing ([basic.lookup.qual])</u>.</li>
<li><s>[…]</s></li>
</ol>
<p><u>A class member access expression is dependent if its <em>id-expression</em> is.</u></p>
</blockquote>
<p>Change paragraph 7:</p>
<blockquote>
<p>If a <s><em>qualified-id</em> in which the <em>nested-name-specifier</em> refers to</s><u>qualified name (but not a member-qualified name that is a <em>nested-name-specifier</em>) whose lookup context is</u> the current instantiation is <u>not dependent and is </u>not a member of the current instantiation<s> or a member of an unknown specialization</s>, the program is ill-formed even if the template <u>whose definition </u>contain<s>ing</s><u>s</u> the <s><em>qualified-id</em></s><u>qualified name</u> is not instantiated; no diagnostic required. <s>Similarly, if the <em>id-expression</em> in a class member access expression for which the type of the object expression is the current instantiation does not refer to a member of the current instantiation or a member of an unknown specialization, the program is ill-formed even if the template containing the member access expression is not instantiated; no diagnostic required.</s> [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 8:</p>
<blockquote>
<p>If, for a given set of template arguments, a specialization of a template is instantiated that refers to a member of the current instantiation with a <s><em>qualified-id</em> or class member access expression</s><u>qualified name</u>, <s>the</s><u>its terminal</u> name<s> in the <em>qualified-id</em> or class member access expression</s> is looked up in the template instantiation context. If the result of this lookup differs from the result of name lookup in the template definition context, name lookup is ambiguous. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 9:</p>
<blockquote>
<p>A type is dependent if it is</p>
<ol style="list-style-type: decimal">
<li>a template parameter,</li>
<li><u>denoted by </u>a <s>member of an unknown specialization</s><u>(qualified) dependent name</u>,</li>
<li>a nested class or enumeration that is a <s>dependent</s><u>direct</u> member of <u>a class that is </u>the current instantiation,</li>
<li>a cv-qualified type where the cv-unqualified type is dependent,</li>
<li>a compound type constructed from any dependent type,</li>
<li>an array type whose element type is dependent or whose bound (if any) is value-dependent,</li>
<li>a function type whose exception specification is value-dependent,</li>
<li>denoted by a <em>simple-template-id</em> in which either the template name is a template parameter or any of the template arguments is a dependent type or an expression that is type-dependent or value-dependent or is a pack expansion [<em>Note</em>: This includes an injected-class-name ([class]) of a class template used without a <em>template-argument-list</em>. — <em>end note</em>], or</li>
<li>denoted by <code>decltype(</code><em>expression</em><code>)</code>, where <em>expression</em> is type-dependent ([temp.dep.expr]).</li>
</ol>
</blockquote>
<h5 id="temp.dep.expr">[temp.dep.expr]</h5>
<p>Change paragraph 2:</p>
<blockquote>
<p><code>this</code> is type-dependent if the <u>current </u>class<s> type of the enclosing member function</s> is dependent ([temp.dep.type]).</p>
</blockquote>
<p>Change paragraph 3:</p>
<blockquote>
<p>An <em>id-expression</em> is type-dependent if it contains</p>
<ol style="list-style-type: decimal">
<li>a<s>n <em>identifier</em></s><u> name</u> associated by name lookup with one or more declarations declared with a dependent type,</li>
<li>a<s>n <em>identifier</em></s><u> name</u> associated by name lookup with a non-type <em>template-parameter</em> declared with a type that contains a placeholder type ([dcl.spec.auto]),</li>
<li>a<s>n <em>identifier</em></s><u> name</u> associated by name lookup with a variable declared with a type that contains a placeholder type ([dcl.spec.auto]) where the initializer is type-dependent,</li>
<li>a<s>n <em>identifier</em></s><u> name</u> associated by name lookup with one or more declarations of member functions of <u>a class that is </u>the current instantiation declared with a return type that contains a placeholder type,</li>
<li>a<s>n <em>identifier</em></s><u> name</u> associated by name lookup with a structured binding declaration ([dcl.struct.bind]) whose <em>brace-or-equal-initializer</em> is type-dependent,</li>
<li>the <em>identifier</em> <code>__func__</code> ([dcl.fct.def.general]), where any enclosing function is a template, a member of a class template, or a generic lambda,</li>
<li>a <em>template-id</em> that is dependent,</li>
<li>a <em>conversion-function-id</em> that specifies a dependent type, or</li>
<li>a <s><em>nested-name-specifier</em> or a <em>qualified-id</em> that names a member of an unknown specialization</s><u>dependent name</u>;</li>
</ol>
<p>or if it names a <s>dependent</s><u>direct</u> member of <u>a class that is </u>the current instantiation that is a static data member of type “array of unknown bound of <code>T</code>” for some <code>T</code> ([temp.static]). Expressions of the following forms are type-dependent only if the type specified by the <em>type-id</em>, <em>simple-type-specifier</em> or <em>new-type-id</em> is dependent, even if any subexpression is type-dependent:</p>
<blockquote>
<p>[…]</p>
</blockquote>
</blockquote>
<p>Change paragraph 5:</p>
<blockquote>
<p>A class member access expression ([expr.ref]) is type-dependent if <s>the expression</s><u>it is dependent or it</u> refers to a member of the current instantiation and the type of the referenced member is dependent<s>, or the class member access expression refers to a member of an unknown specialization</s>. [<em>Note</em>: In an expression of the form <code>x.y</code> or <code>xp-&gt;y</code> the type of the expression is usually the type of the member <code>y</code> of the class of <code>x</code> (or the class pointed to by <code>xp</code>). However, if <code>x</code> or <code>xp</code> refers to a dependent type that is not the current instantiation, the type of <code>y</code> is always dependent. <s>If <code>x</code> or <code>xp</code> refers to a non-dependent type or refers to the current instantiation, the type of <code>y</code> is the type of the class member access expression.</s> — <em>end note</em>]</p>
</blockquote>
<h5 id="temp.dep.temp">[temp.dep.temp]</h5>
<p>Change paragraph 4:</p>
<blockquote>
<p>A template <em>template-argument</em> is dependent if it names a <em>template-parameter</em> or is a <s><em>qualified-id</em> that refers to a member of an unknown specialization</s><u>dependent name</u>.</p>
</blockquote>
<h4 id="temp.nondep">[temp.nondep]</h4>
<p>Remove subclause, referring the stable name to [temp.res] and removing the one cross reference (in [basic.def.odr]/12).</p>
<h4 id="temp.dep.candidate">[temp.dep.candidate]</h4>
<p>Change paragraph 1:</p>
<blockquote>
<p><s>For a function call where the <em>postfix-expression</em> is a dependent name, the candidate functions are found using the usual lookup rules from the template definition context ([basic.lookup.unqual], [basic.lookup.argdep]). [<em>Note</em>: For the part of the lookup using associated namespaces ([basic.lookup.argdep]), function declarations found in the template instantiation context are found by this lookup, as described in [basic.lookup.argdep]. — <em>end note</em>]</s> If <s>the</s><u>a function</u> call<u> whose <em>postfix-expression</em> is an unqualified dependent name</u> would be ill-formed or would find a better match had the lookup<u> for the name</u> within the associated namespaces considered all the function declarations with external linkage introduced in those namespaces in all translation units, not just considering those declarations found in the template definition and template instantiation contexts<u> ([basic.lookup.argdep])</u>, then the program <s>has undefined behavior</s><u>is ill-formed, no diagnostic required</u>.</p>
</blockquote>
<h4 id="temp.inject">[temp.inject]</h4>
<p>Change paragraph 1:</p>
<blockquote>
<p>Friend classes<s> or</s><u>, class templates,</u> functions<u>, or function templates</u> can be declared within a class template. When a template is instantiated, <s>the names of </s>its friend<s>s</s><u> declarations</u> are treated as if the specialization had been explicitly declared at its point of instantiation.</p>
</blockquote>
<p>Remove paragraph 2.</p>
<h3 id="temp.spec">[temp.spec]</h3>
<p>Change paragraph 3:</p>
<blockquote>
<p>An explicit specialization may be declared for a function template, a variable template, a class template, a member of a class template, or a member template. An explicit specialization declaration is introduced by <code>template&lt;&gt;</code>. In an explicit specialization declaration for a variable template, a class template, a member of a class template or a class member template, <s>the name of </s>the variable or class that is explicitly specialized shall be <u>specified with </u>a <em>simple-template-id</em>. In the explicit specialization declaration for a function template or a member function template, <s>the name of </s>the function or member function explicitly specialized may be <u>specified using </u>a <em>template-id</em>. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<h4 id="temp.explicit">[temp.explicit]</h4>
<p>Change paragraph 4:</p>
<blockquote>
<p>If the explicit instantiation is for a class or member class, the <em>elaborated-type-specifier</em> in the <em>declaration</em> shall include a <em>simple-template-id</em>; otherwise, the <em>declaration</em> shall be a <em>simple-declaration</em> whose <em>init-declarator-list</em> comprises a single <em>init-declarator</em> that does not have an <em>initializer</em>. <s>If the explicit instantiation is for a function or member function, the <em>unqualified-id</em> in the <em>declarator</em> shall be either a <em>template-id</em> or, where all template arguments can be deduced, a <em>template-name</em> or <em>operator-function-id</em>. [<em>Note</em>: The declaration may declare a <em>qualified-id</em>, in which case the <em>unqualified-id</em> of the <em>qualified-id</em> must be a <em>template-id</em>. — <em>end note</em>]</s> If the explicit instantiation is for a member function, a member class or a static data member of a class template specialization, <s>the name of </s>the class template specialization <u>shall be named </u>in the <em>qualified-id</em> <s>for the member name shall be</s><u>with</u> a <em>simple-template-id</em>. If the explicit instantiation is for a variable template specialization, the <em>unqualified-id</em> in the <em>declarator</em> shall be a <em>simple-template-id</em>. <s>An explicit instantiation shall appear in an enclosing namespace of its template. If the name declared in the explicit instantiation is an unqualified name, the explicit instantiation shall appear in the namespace where its template is declared or, if that namespace is inline ([namespace.def]), any namespace from its enclosing namespace set. [<em>Note</em>: Regarding qualified names in declarators, see [dcl.meaning]. — <em>end note</em>]</s> [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 5:</p>
<blockquote>
<p><u>An explicit instantiation does not introduce a name ([basic.scope.scope]).</u> A declaration of a function template, a variable template, a member function or static data member of a class template, or a member function template of a class or class template shall <s>precede</s><u>be reachable from</u> an<u>y</u> explicit instantiation of that entity. A definition of a class template, a member class of a class template, or a member class template of a class or class template shall <s>precede</s><u>be reachable from</u> an<u>y</u> explicit instantiation of that entity unless <s>the explicit instantiation is preceded by </s>an explicit specialization of the entity with the same template arguments<u> is reachable therefrom</u>. If the <em>declaration</em> of the explicit instantiation names an implicitly-declared special member function ([special]), the program is ill-formed.</p>
</blockquote>
<p>Remove paragraph 8.</p>
<p>Change paragraph 9:</p>
<blockquote>
<p>A trailing <em>template-argument</em> can be left unspecified in an explicit instantiation of a function template specialization or of a member function template specialization provided it can be deduced from the type of a function parameter ([temp.deduct]). <u>If all template arguments can be deduced, the empty template argument list <code>&lt;&gt;</code> may be omitted.</u> [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<h4 id="temp.expl.spec">[temp.expl.spec]</h4>
<p>Change paragraph 4:</p>
<blockquote>
<p><u>An explicit specialization does not introduce a name ([basic.scope.scope]).</u> A declaration of a function template, class template, or variable template being explicitly specialized shall <s>precede</s><u>be reachable from</u> the declaration of the explicit specialization. [<em>Note</em>: A declaration, but not a definition of the template is required. — <em>end note</em>] The definition of a class or class template shall <s>precede</s><u>be reachable from</u> the declaration of an explicit specialization for a member template of the class or class template. [<em>Example</em>:</p>
<p>[…]</p>
<p>— <em>end example</em>]</p>
</blockquote>
<p>Change paragraph 5:</p>
<blockquote>
<p>A member function, a member function template, a member class, a member enumeration, a member class template, a static data member, or a static data member template of a class template may be explicitly specialized for a class specialization that is implicitly instantiated; in this case, the definition of the class template shall <s>precede</s><u>be reachable from</u> the explicit specialization for the member of the class template. If such an explicit specialization for the member of a class template names an implicitly-declared special member function ([special]), the program is ill-formed.</p>
</blockquote>
<p>Remove paragraph 9.</p>
<h3 id="temp.fct.spec">[temp.fct.spec]</h3>
<h4 id="temp.deduct.conv">[temp.deduct.conv]</h4>
<p>Change paragraph 1:</p>
<blockquote>
<p>Template argument deduction is done by comparing the return type of the conversion function template (call it <code>P</code>) with the type <s>that is required as the result</s><u>specified by the <em>conversion-type-id</em></u> of the <s>conversion</s><u><em>conversion-function-id</em></u> (call it <code>A</code><s>; see [dcl.init], [over.match.conv], and [over.match.ref] for the determination of that type</s>) as described in [temp.deduct.type]. <u>If the <em>conversion-function-id</em> is constructed during overload resolution ([over.match.funcs]), the following transformations apply.</u></p>
</blockquote>
<p>Change paragraph 5:</p>
<blockquote>
<p>In general, the deduction process attempts to find template argument values that will make the deduced <code>A</code> identical to <code>A</code>. However, <s>there are four cases that allow a difference</s><u>certain attributes of <code>A</code> may be ignored</u>:</p>
<ol style="list-style-type: decimal">
<li>If the original <code>A</code> is a reference type, <u>any cv-qualifiers of </u><code>A</code><s> can be more cv-qualified than the deduced <code>A</code></s> (i.e., the type referred to by the reference)<u>,</u></li>
<li>If the original <code>A</code> is a function pointer<u> or pointer-to-member-function</u> type, <s><code>A</code> can be “pointer to function” even if the deduced <code>A</code> is “pointer to </s><u>its </u><code>noexcept</code><s> function”.</s><u>, if any, and</u></li>
<li><s>If the original <code>A</code> is a pointer-to-member-function type, <code>A</code> can be “pointer to member of type function” even if the deduced <code>A</code> is “pointer to member of type <code>noexcept</code> function”.</s></li>
<li><s>The deduced</s><u>Any cv-qualifiers in</u> <code>A</code> <s>can be another pointer or pointer-to-member type </s>that can be <s>converted to <code>A</code> via</s><u>restored by</u> a qualification conversion.</li>
</ol>
</blockquote>
<p>Change paragraph 6:</p>
<blockquote>
<p>These <s>alternatives</s><u>attributes</u> are <s>considered</s><u>ignored</u> only if type deduction would otherwise fail. If <s>they yield</s><u>ignoring them allows</u> more than one possible deduced <code>A</code>, the type deduction fails.</p>
</blockquote>
<h4 id="temp.over">[temp.over]</h4>
<p>Change paragraph 1:</p>
<blockquote>
<p>When a call <s>to the name </s>of a function or function template is written (explicitly, or implicitly using the operator notation), template argument deduction ([temp.deduct]) and checking of any explicit template arguments ([temp.arg]) are performed for each function template to find the template argument values (if any) that can be used with that function template to instantiate a function template specialization that can be invoked with the call arguments. For each function template, if the argument deduction and checking succeeds, the <em>template-argument</em>⁠s (deduced and/or explicit) are used to synthesize the declaration of a single function template specialization which is added to the candidate functions set to be used in overload resolution. If, for a given function template, argument deduction fails or the synthesized function template specialization would be ill-formed, no such function is added to the set of candidate functions for that template. The complete set of candidate functions includes all the synthesized declarations and all of the non-template <s>overloaded </s>functions <s>of the same name</s><u>found by name lookup</u>. The synthesized declarations are treated like any other functions in the remainder of overload resolution, except as explicitly noted in [over.match.best].<sup>[…]</sup></p>
</blockquote>
<h2 id="except.handle">[except.handle]</h2>
<p>Remove paragraph 11.</p>
<h2 id="diff.basic">[diff.basic]</h2>
<p>Change paragraph 2 (the example is based on that from the removed [class.nested.type]):</p>
<blockquote>
<p><strong>Affected subclause:</strong> [basic.scope]<br /><strong>Change:</strong> A <code>struct</code> is a scope in C++, not in C.<br /><u>For example,</u></p>
<pre class="sourceCode cpp ins"><code class="sourceCode cpp"><span class="kw">struct</span> X {
  <span class="kw">struct</span> Y { <span class="dt">int</span> a; } b;
};
<span class="kw">struct</span> Y c;</code></pre>
<p><u>is valid in C but not in C++, which would require <code>X::Y c;</code>.</u><br /><strong>Rationale:</strong> Class scope is crucial to C++, and a struct is a class.<br /><strong>Effect on original feature:</strong> Change to semantics of well-defined feature.<br /><strong>Difficulty of converting:</strong> Semantic transformation.<br /><strong>How widely used:</strong> C programs use <code>struct</code> extremely frequently, but the change is only noticeable when <code>struct</code>, enumeration, or enumerator names are referred to outside the <code>struct</code>. The latter is probably rare.</p>
</blockquote>
<h2 id="depr.template.template">[depr.template.template]</h2>
<p>Add this subclause before [depr.c.headers]:</p>
<blockquote>
<p>The use of the keyword <code>template</code> before the qualified name of a class or alias template without a template argument list is deprecated.</p>
</blockquote>
<h1 id="acknowledgments">Acknowledgments</h1>
<p>Thanks to Richard Smith for helping discover and interpret several of the issues addressed and for feedback on their resolutions, and to Rachel Ertl for helping decide on them.</p>
</body>
</html>
