This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-04-18


962. Attributes appertaining to class and enum types

Section: 9.2.9.5  [dcl.type.elab]     Status: CD2     Submitter: Daveed Vandevoorde     Date: 2 September, 2009

[Voted into WP at March, 2010 meeting.]

There is a lack of symmetry in the specification of attributes that apply to class and enum types. For example:

    class X [[attr]];               // #1
    typedef class Y [[attr]] YT;    // #2

According to 9.2.9.5 [dcl.type.elab] paragraph 1, #1 associates the attr attribute with class X for all subsequent references. On the other hand, 9.3.4 [dcl.meaning] paragraph 5 says that #2 associates the attr attribute with the type but not with class Y.

Existing implementations (Microsoft, GNU, Sun) with attributes place an attribute that is intended to be associated with a class type between the class-key and the class name, and it would be preferable to adopt such an approach instead of the contextual approach in the current formulation.

Proposed resolution (October, 2009):

  1. Change 6.4.2 [basic.scope.pdecl] bullet 6.1 as follows:

  2. Change 6.5.6 [basic.lookup.elab] paragraph 2 as follows:

  3. ...unless the elaborated-type-specifier appears in a declaration with the following form:

    the identifier is looked up... if the elaborated-type-specifier appears in a declaration with the form:

    the elaborated-type-specifier is a declaration...

  4. In 9.2.9.5 [dcl.type.elab], change the grammar and paragraph 1 as follows:

  5. An attribute-specifier shall not appear in an elaborated-type-specifier unless the latter is the sole constituent of a declaration. If an elaborated-type-specifier is the sole constituent of a declaration, the declaration is ill-formed unless it is an explicit specialization (13.9.4 [temp.expl.spec]), an explicit instantiation (13.9.3 [temp.explicit]) or it has one of the following forms:

  6. Change the grammar in 9.7.1 [dcl.enum] paragraph 1 as follows:

  7. Change the grammar in Clause 11 [class] paragraph 1 as follows: