Is it the intent of the standard that any form `nested-type-specifier followed by an identifier` can be called a qualified-id

Viewed 97

This is a simplified question derived from here

struct A{
  using type = int;
};
int main(){
  A::type variable;  //#1
}

For the declaration at #1, it's consisted of a type-specifier and a declarator. In more detail, the type-specifier is a simple-type-specifier that has the form: dcl.type.simple

nested-name-specifier opt type-name

Usually, the name type is a qualified name that should be lookup in the scope of A. However, the following rules do not say so.
basic.lookup.qual#general-2.4

A qualified name is

  • a member-qualified name or
  • the terminal name of
    • a qualified-id,
    • a using-declarator
    • a typename-specifier
    • a qualified-namespace-specifier, or
    • a nested-name-specifier, elaborated-type-specifier, or class-or-decltype that has a nested-name-specifier ([expr.prim.id.qual]).

The list does not mention the simple-type-specifier which has the form nested-name-specifier type-name. I don't know whether the rule intends to use qualified-id to cover this case(I'm not sure). If it is, I have to say a simple-type-specifer is not a qualified-id, although they all can have the form, which is a nested-type-specifier followed by an identifier. In my mind, a qualified-id is designated by the grammar which comprises a qualified-id. For example

postfix-expression . templateopt id-expression

Where the id-expression might be a qualified-id. In this case, the notation that appears in the id-expression which has the form nested-name-specifier identifier is called a qualified-id(i.e, what can it be called is designated by the grammar).

A simple-type-specifier that has the form nested-name-specifier identifier has a different syntactic meaning with a qualified-id that has the same form. At least, a simple-type-specifier cannot be called a qualified-id since we cannot find the syntax qualified-id in the grammar tree of the type-specifier. Similar things are so many somewhere in the standard(such as the aforementioned question). Is it a defect of the standard(It intends to use qualified-id to cover other notations that have the form nested-name-specifier identifier)?

1 Answers

It could be argued that this is an omission, but until name lookup takes place it’s not generally possible to know whether nested-name-specifier identifier is a simple-type-specifier or a qualified-id. The rule is written in terms of the latter as a sort of default interpretation, as in the case of a dependent name where the lookup can’t even happen during parsing. We then unconditionally call it a qualified-id that in some cases “is considered to denote a type”.

Related