Skip to content

[basic.pre,basic.link] Clarify 'declaration of entity' vs. namespace-alias #4833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
23 changes: 19 additions & 4 deletions source/basic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,16 @@
The interpretation of a \grammarterm{for-range-declaration} produces
one or more of the above\iref{stmt.ranged}.
\end{note}
An entity $E$ is denoted by the name (if any)
that is introduced by a declaration of $E$ or
by a \grammarterm{typedef-name} introduced by a declaration specifying $E$.
An entity $E$ is denoted by
\begin{itemize}
\item
the name (if any) that is introduced by a declaration of $E$, or
\item
a \grammarterm{typedef-name} introduced by a declaration specifying $E$, or
\item
a \grammarterm{namespace-alias} introduced by
a \grammarterm{namespace-alias-definition} denoting $E$.
\end{itemize}

\pnum
A \defn{variable} is introduced by the
Expand Down Expand Up @@ -2716,7 +2723,15 @@
they both declare names with external linkage.
\end{itemize}
\begin{note}
There are other circumstances in which declarations declare the same entity%
An \grammarterm{alias-declaration}\iref{dcl.typedef},
Copy link
Contributor

@xmh0511 xmh0511 Aug 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using type = struct A{};? Moreover, since alias-declaration does not declare any entity why doesn't the declaration with typedef specifier do?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's true that an alias-declaration can contain a declaration of an entity, but I think it's clear here that it is the direct effect of the top-most declaration that is in question.

I'm not sure I understand the second question, although note that the paragraph begins by "enabling" names for linkage for purposes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think alias-declaration and declaration specified with typedef should have the same treatment since they are merely different ways to declare the identifier to be a typedef-name. In line 2690, we just say alias-declaration but do not mention the declaration with typedef specifier, it's the second question.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not add this note instead to [basic.pre]/5 (changed above), perhaps phrased as

A typedef-name or namespace-alias is not itself an entity. A using-declarator does not introduce an entity.

? I think namespace-alias-definition is then covered by implication. (The non-parallelism in that wording results from the lack of a pseudo-grammar term like using-name to distinguish identifiers with such a declaration, which I regard as no great omission.)

If we prefer to leave it here, I think it goes better after the "other circumstances" note (which is more directly related to the paragraph).

a \grammarterm{using-declarator}\iref{namespace.udecl}, or
a \grammarterm{namespace-alias-definition}\iref{namespace.alias}
does not declare any entities;
a \grammarterm{typedef-name} or \grammarterm{namespace-alias}
is not an entity\iref{basic.pre}.
\end{note}
\begin{note}
There are other circumstances in which declarations declare the same entity
\iref{dcl.link,temp.type,temp.spec.partial}.
\end{note}

Expand Down