-
Notifications
You must be signed in to change notification settings - Fork 771
[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
base: main
Are you sure you want to change the base?
Conversation
@opensdh, any opinion here? |
Maybe, change the link at the end of the first sentence of [basic.scope.scope] p4 to let it links to [basic.pre] p5. It is clearer.
Since it talks about what's entity the name denotes. [basic.pre] p5 is exactly talking about what the entity the corresponding name introduced by the declaration denotes. For an entity E is denoted by the name (if any) that is introduced by a declaration of E, we can determine whether these two declarations declare the same entity or not as per [basic.link] in order to judge whether the names introduced by a declaration that declares an entity denote the same entity or not. For the remaining case, such as typedef-name or namespace-alias, we can judge them by checking whether the declaration specifying the same entity. |
We still need a cross-reference to basic.link for "same entity" somewhere in the (logical) vicinity. |
Yes. However, the reference to [basic.link] can be indirectly referenced by [basic.pre] p5. Consider the first sentence
If there are two declarations that declare entities, which both introduced the shared name "N", that sentence says "N" denotes the entity E introduced by the declaration. Hence, if we want to judge whether the shared name "N" denotes the same entity, we should first determine whether the two declarations declare the same entity, which needs the help of [basic.link]. The remaining case is these names introduced by declarations that do not declare entities. [basic.link] does not cover this case, but [basic.pre] p5 does. If possible, the following is a better case
|
@@ -2680,6 +2687,14 @@ | |||
they both declare names with external linkage. | |||
\end{itemize} | |||
\begin{note} | |||
An \grammarterm{alias-declaration}\iref{dcl.typedef}, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@@ -2680,6 +2687,14 @@ | |||
they both declare names with external linkage. | |||
\end{itemize} | |||
\begin{note} | |||
An \grammarterm{alias-declaration}\iref{dcl.typedef}, |
There was a problem hiding this comment.
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.
@@ -2680,6 +2687,14 @@ | |||
they both declare names with external linkage. | |||
\end{itemize} | |||
\begin{note} | |||
An \grammarterm{alias-declaration}\iref{dcl.typedef}, |
There was a problem hiding this comment.
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).
@opensdh How about #4833 (comment) this opinion? I just think [basic.scope#scope-4] is talking about what's the entity the name denotes. [basic.pre] p5 is directly related to [basic.scope#scope-4]. Instead, [basic.link] p8 is just an indirect rule about whether the name denotes the same entity if the declaration does declare the entity. |
I think we're generally in agreement. |
Fixes #4787