Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions source/basic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -987,14 +987,32 @@
\end{codeblock}
\end{example}

\pnum
A declaration is \defnx{name-independent}{declaration!name-independent}
if its name is \tcode{_} (\unicode{005f}{low line}) and it declares
a variable with automatic storage duration,
a structured binding not inhabiting a namespace scope,
the variable introduced by an \grammarterm{init-capture}, or
a non-static data member.

\recommended
Implementations should not emit a warning
that a name-independent declaration is used or unused.

\pnum
\indextext{declaration!potentially conflict}%
Two declarations \defn{potentially conflict}
if they correspond and
cause their shared name to denote different entities\iref{basic.link}.
The program is ill-formed
if, in any scope, a name is bound to two declarations
that potentially conflict and one precedes the other\iref{basic.lookup}.
if, in any scope, a name is bound to two declarations $A$ and $B$
that potentially conflict and $A$ precedes $B$\iref{basic.lookup},
unless $B$ is name-independent.
\begin{note}
An \grammarterm{id-expression} that names a unique name-independent declaration
is usable until an additional declaration of the same name
is introduced in the same scope\iref{basic.lookup.general}.
\end{note}
\begin{note}
Overload resolution can consider potentially conflicting declarations
found in multiple scopes
Expand All @@ -1015,6 +1033,18 @@
namespace B = B; // OK, no effect
namespace A = B; // OK, no effect
namespace B {} // error: different entity for \tcode{B}

void g() {
int _;
_ = 0; // OK
int _; // OK, name-independent declaration
_ = 0; // error: two non-function declarations in the lookup set
}
void h () {
int _; // \#1
_ ++; // OK
static int _; // error: conflicts with \#1 because static variables are not name-independent
}
\end{codeblock}
\end{example}

Expand Down Expand Up @@ -1236,7 +1266,9 @@
\end{example}

\pnum
If a declaration whose target scope is the block scope $S$ of a
If a declaration
that is not a name-independent declaration and
whose target scope is the block scope $S$ of a
\begin{itemize}
\item
\grammarterm{compound-statement} of a \grammarterm{lambda-expression},
Expand Down Expand Up @@ -2728,6 +2760,7 @@
for linkage purposes, if any\iref{dcl.typedef,dcl.enum},
they correspond\iref{basic.scope.scope},
have the same target scope that is not a function or template parameter scope,
neither is a name-independent declaration,
and either
\begin{itemize}
\item
Expand Down
16 changes: 14 additions & 2 deletions source/declarations.tex
Original file line number Diff line number Diff line change
Expand Up @@ -8055,9 +8055,21 @@

\pnum
If a declaration named by a \grammarterm{using-declaration}
that inhabits the target scope of another declaration
that inhabits the target scope of another declaration $B$
potentially conflicts with it\iref{basic.scope.scope}, and
either is reachable from the other, the program is ill-formed.
either is reachable from the other, the program is ill-formed
unless $B$ is name-independent and
the \grammarterm{using-declaration} precedes $B$.
\begin{example}
\begin{codeblock}
int _;
void f() {
int _; // B
_ = 0;
using ::_; // error: \grammarterm{using-declaration} does not precede B
}
\end{codeblock}
\end{example}
If two declarations named by \grammarterm{using-declaration}s
that inhabit the same scope potentially conflict,
either is reachable from the other, and
Expand Down
1 change: 1 addition & 0 deletions source/preprocessor.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1849,6 +1849,7 @@
\defnxname{cpp_nontype_template_args} & \tcode{201911L} \\ \rowsep
\defnxname{cpp_nontype_template_parameter_auto} & \tcode{201606L} \\ \rowsep
\defnxname{cpp_nsdmi} & \tcode{200809L} \\ \rowsep
\defnxname{cpp_placeholder_variables} & \tcode{202306L} \\ \rowsep
\defnxname{cpp_range_based_for} & \tcode{202211L} \\ \rowsep
\defnxname{cpp_raw_strings} & \tcode{200710L} \\ \rowsep
\defnxname{cpp_ref_qualifiers} & \tcode{200710L} \\ \rowsep
Expand Down