Title
Attributes appertaining to class and enum types
Status
cd2
Section
9.2.9.5 [dcl.type.elab]
Submitter
Daveed Vandevoorde

Created on 2009-09-02.00:00:00 last changed 178 months ago

Messages

Date: 2010-03-15.00:00:00

[Voted into WP at March, 2010 meeting.]

Date: 2009-10-15.00:00:00

Proposed resolution (October, 2009):

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

    • for a declaration of the form

      • class-key attribute-specifieropt identifier attribute-specifieropt ;

      the identifier is declared...

  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:

      class-key attribute-specifieropt identifier attribute-specifieropt ;

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

      class-key attribute-specifieropt identifier attribute-specifieropt ;

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

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

    • elaborated-type-specifier:
        class-key attribute-specifieropt ::opr nested-name-specifieropt identifier
        ...

    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:

      class-key attribute-specifieropt identifier attribute-specifieropt ;
      ...
  5. Change the grammar in 9.7.1 [dcl.enum] paragraph 1 as follows:

    • enum-head:
        enum-key attribute-specifieropt identifieropt attribute-specifieropt enum-baseopt attribute-specifieropt
        enum-key attribute-specifieropt nested-name-specifier identifier
          attribute-specifieropt enum-baseopt attribute-specifieropt

      opaque-enum-declaration:
        enum-key attribute-specifieropt identifier attribute-specifieropt enum-baseopt attribute-specifieropt
  6. Change the grammar in Clause 11 [class] paragraph 1 as follows:

    • class-head:
        class-key attribute-specifieropt identifieropt attribute-specifieropt base-clauseopt
        class-key attribute-specifieropt nested-name-specifier identifier attribute-specifieropt base-clauseopt
        class-key attribute-specifieropt nested-name-specifieropt simple-template-id
          attribute-specifieropt base-clauseopt
Date: 2009-09-02.00:00:00

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.

History
Date User Action Args
2010-03-29 00:00:00adminsetmessages: + msg2688
2010-03-29 00:00:00adminsetstatus: ready -> cd2
2009-11-08 00:00:00adminsetmessages: + msg2350
2009-11-08 00:00:00adminsetstatus: open -> ready
2009-09-02 00:00:00admincreate