Skip to content
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

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jensmaurer
Copy link
Member

Fixes #4787

@jensmaurer jensmaurer added decision-required A decision of the editorial group (or the Project Editor) is required. and removed decision-required A decision of the editorial group (or the Project Editor) is required. labels Aug 21, 2021
@jensmaurer
Copy link
Member Author

@opensdh, any opinion here?

@xmh0511
Copy link
Contributor

xmh0511 commented Aug 21, 2021

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.

Two declarations potentially conflict if they correspond and cause their shared name to denote different entities ([basic.pre]).

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.

@jensmaurer
Copy link
Member Author

We still need a cross-reference to basic.link for "same entity" somewhere in the (logical) vicinity.

@xmh0511
Copy link
Contributor

xmh0511 commented Aug 21, 2021

Yes. However, the reference to [basic.link] can be indirectly referenced by [basic.pre] p5. Consider the first sentence

An entity E is denoted by the name (if any) that is introduced by a declaration of E.

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

Two declarations potentially conflict if they correspond and cause their shared name to denote different entities ([basic.pre],[basic.link]).

@@ -2680,6 +2687,14 @@
they both declare names with external linkage.
\end{itemize}
\begin{note}
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.

@@ -2680,6 +2687,14 @@
they both declare names with external linkage.
\end{itemize}
\begin{note}
An \grammarterm{alias-declaration}\iref{dcl.typedef},
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.

@@ -2680,6 +2687,14 @@
they both declare names with external linkage.
\end{itemize}
\begin{note}
An \grammarterm{alias-declaration}\iref{dcl.typedef},
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).

@xmh0511
Copy link
Contributor

xmh0511 commented Aug 24, 2021

@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.

@opensdh
Copy link
Contributor

opensdh commented Aug 24, 2021

@opensdh How about #4833 (comment) this opinion?

I think we're generally in agreement.

@wg21bot wg21bot added the needs rebase The pull request needs a git rebase to resolve merge conflicts. label Feb 22, 2022
@jensmaurer jensmaurer added changes requested Changes to the wording or approach have been requested and not yet applied. and removed needs rebase The pull request needs a git rebase to resolve merge conflicts. labels Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes requested Changes to the wording or approach have been requested and not yet applied.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[basic.scope.scope] The meaning of "denote different entities" is vague
4 participants