Title
Ambiguity due to optional decl-specifier-seq
Status
cd4
Section
Clause [9] [dcl.dcl]
Submitter
Hubert Tong

Created on 2014-08-27.00:00:00 last changed 49 months ago

Messages

Date: 2015-10-15.00:00:00

[Moved to DR at the October, 2015 meeting.]

Date: 2015-05-15.00:00:00

Proposed resolution (May, 2015):

  1. Change the grammar in Clause 9 [dcl.dcl] paragraph 1 as follows:

    • declaration:
        block-declaration
        nodeclspec-function-declaration
        function_definition
      ...

      nodeclspec-function-declaration:
        attribute-specifier-seqopt declarator ;

      alias-declaration:
        using identifier attribute-specifier-seqopt = type-id ;

      simple-declaration:
        decl-specifier-seqopt init-declarator-list ;
        attribute-specifier-seq decl-specifier-seqopt init-declarator-list ;
      ...
  2. Change Clause 9 [dcl.dcl] paragraph 2 as follows:

  3. The A simple-declaration or nodeclspec-function-declaration of the form

      attribute-specifier-seqopt decl-specifier-seqopt init-declarator-listopt ;

    is divided into three parts. Attributes are described in 9.12 [dcl.attr]. decl-specifiers, the principal components of a decl-specifier-seq, are described in 9.2 [dcl.spec]. declarators, the components of an init-declarator-list, are described in Clause 9.3 [dcl.decl]. The attribute-specifier-seq in a simple-declaration appertains to each of the entities declared by the declarators of the init-declarator-list. [Note:...

  4. Change Clause 9 [dcl.dcl] paragraph 11 as follows:

  5. Only in function declarations for A nodeclspec-function-declaration shall declare a constructors, destructors, and type or conversions function can the decl-specifier-seq be omitted.93 [Note: a nodeclspec-function-declaration can only be used in a template-declaration (Clause Clause 13 [temp]), explicit-instantiation (13.9.3 [temp.explicit]), or explicit-specialization (13.9.4 [temp.expl.spec]). —end note]
  6. Change 9.3.4 [dcl.meaning] paragraph 1 as follows:

  7. A list of declarators appears after an optional (Clause Clause 9 [dcl.dcl]) decl-specifier-seq (9.2 [dcl.spec]). Each A declarator contains exactly one declarator-id; it names the identifier...
  8. Change 11.4.5 [class.ctor] paragraph 1 as follows:

  9. ...In a constructor declaration, each Each decl-specifier in the optional decl-specifier-seq of a constructor declaration (if any) shall be friend, inline, explicit, or constexpr. [Example:...
  10. Change 11.4.8.3 [class.conv.fct] paragraph 1 as follows:

  11. ...Such functions are called conversion functions. No return type can be specified. A decl-specifier in the decl-specifier-seq of a conversion function (if any) shall be neither a type-specifier nor static. If a conversion function is a member function, the The type of the conversion function (9.3.4.6 [dcl.fct]) is...
  12. Delete 11.4.8.3 [class.conv.fct] paragraph 6:

  13. Conversion functions cannot be declared static.
  14. Change 11.4.7 [class.dtor] paragraph 1 as follows:

  15. ...In a destructor declaration, each Each decl-specifier of the optional decl-specifier-seq of a destructor declaration (if any) shall be friend, inline, or virtual.

This resolution also resolves issue 2016.

Date: 2014-08-27.00:00:00

In an example like

  void f() {
    f();  // #1
  }

The statement at #1 is ambiguous and can be parsed as either an expression or as a declaration. The problem is the fact that the decl-specifier-seq in a simple-declaration is optional.

History
Date User Action Args
2017-02-06 00:00:00adminsetstatus: dr -> cd4
2015-11-10 00:00:00adminsetmessages: + msg6071
2015-11-10 00:00:00adminsetstatus: ready -> dr
2015-05-25 00:00:00adminsetmessages: + msg5453
2015-05-25 00:00:00adminsetstatus: drafting -> ready
2014-08-27 00:00:00admincreate