cplusplus / CWG

Core Working Group
23 stars 7 forks source link

[dcl.pre] What entity the declaration declares is not explicitly specified #438

Open xmh0511 opened 9 months ago

xmh0511 commented 9 months ago

Full name of submitter (unless configured in github; will be published with the issue): Jim X

There are many rules in the document that check whether a declaration declares a specific entity. However, in [dcl.pre], or relevant subclause(e.g. [class.pre]), we just don't explicitly specify what entity the declaration declares, instead, they are always implicitly conveyed.

[dcl.pre] p7

If the decl-specifier-seq contains the typedef specifier, the declaration is a typedef declaration and each declarator-id is declared to be a typedef-name, synonymous with its associated type ([dcl.typedef]).

In this sentence, the rule explicitly says that the declarations declare typedef-name, so, we can understand that the declarations do not declare any entity but a name.

However, when we read [class.pre], [dcl.type.elab] p2, and [dcl.type.elab] p3

A class-specifier or an elaborated-type-specifier ([dcl.type.elab]) is used to make a class-name.

Otherwise, the class-name is an identifier; it is not looked up, and the class-specifier introduces it.

In the first case, the elaborated-type-specifier declares the identifier as a class-name.

E shall not be introduced by the enum keyword and declares the identifier as a class-name.

So, what does that mean? By the same logic as reading typedef declaration, does it mean these declarations just declare names too because class-name is a name? Presumably, this is not the intent, these declarations should declared the entity(class type).

Moreover, the second part of [dcl.pre] p7, which also does not explicitly say what the entity the declaration declares.

Otherwise, if the type associated with a declarator-id is a function type ([dcl.fct]), the declaration is a function declaration. Otherwise, if the type associated with a declarator-id is an object or reference type, the declaration is an object declaration. Otherwise, the program is ill-formed.

What entities that are declared by these declarations are, which is all based on we have a non-text consensus that X declaration declared the entity X.

Suggested Resolution

Elaborate on what entity the declaration declares, in the relevant clauses.