Go to the first, previous, next, last section, table of contents.


4.9 Context-Dependent Keywords

As in C++, new context-dependent keywords are introduced by various declarations. We use a few more categories of such keywords than the proposed standard grammar does (see Section A.1 of [ANSI95]), because we want to distinguish type definition names and template names for classes from non-classes. Also, note that an original-class-name is the name of something that is a declared as a class. See section 5.2.3.2 Class and Namespace Names for the syntax of class-name and namespace-name. See section 4.6 Identifiers for the syntax of identifier.

context-dependent-keyword ::= typedef-non-class-or-enum-name
    | typedef-class-name | typedef-enum-name
    | original-namespace-name | namespace-alias-name
    | original-class-name | original-enum-name
    | template-non-class-name | template-class-name
typedef-non-class-or-enum-name ::= identifier
typedef-class-name ::= identifier
typedef-enum-name ::= identifier
original-namespace-name ::= identifier
namespace-alias-name ::= identifier
original-class-name ::= identifier
original-enum-name ::= identifier
template-non-class-name ::= identifier
template-class-name ::= identifier

An identifier is recognized as a typedef-class-name if it was declared (in an appropriate scope) by a declaration using the typedef decl-specifier (see section 5.2 Declaration Specifiers), and if it declares a class. Similarly, an identifier is recognized as a typedef-enum-name if it was declared as a typedef to an enum. Other identifiers declared in a typedef declaration are recognized as typedef-non-class-or-enum-names when used later. The same distinction is made in template declarations (see section 8 Template Specifications) between a template-non-class-name and a template-class-name.

Similarly, an identifier is recognized as an original-enum-name if it was declared with an enum-specifier (see section 5.3 Enumeration Declarations). Again, an identifier is recognized as an original-class-name if it was declared with a class-specifier (see section 7 Class Specifications). Similar remarks hold for identifiers recognized as original-namespace-names or namespace-alias-names (see section 5.5 C++ Namespace and Using Declarations).


Go to the first, previous, next, last section, table of contents.