Movatterモバイル変換


[0]ホーム

URL:


Issue 1274 - WG21 CWG Issues
Title
Common nonterminal for expression and braced-init-list
Status
cd4
Section
8.6.5 [stmt.ranged]
Submitter
Daniel Krügler

Created on2011-03-25.00:00:00 last changed109 months ago

Messages

msg6070 (view)
Date: 2015-10-15.00:00:00

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

msg5451 (view)
Date: 2015-05-15.00:00:00

Proposed resolution (May, 2015):

  1. Add a new production to the grammar in 9.5 [dcl.init] paragraph 1:

    • expr-or-braced-init-list:
        expression
        braced-init-list
  2. Change the grammar in 7.6.1 [expr.post] paragraph 1as follows:

    • postfix-expression:
        primary-expression
        postfix-expression[expressionexpr-or-braced-init-list]
        postfix-expression[braced-init-list]
        postfix-expression(expression-listopt)
        ...
  3. Change the grammar in 8.6 [stmt.iter] paragraph 1as follows:

    • for-range-initializer:
        expression
        braced-init-list
        expr-or-braced-init-list
  4. Change 8.6.5 [stmt.ranged] paragraph 1 as follows:

  5. For a range-basedfor statement of the form

      for (for-range-declaration:expression)statement

    letrange-init be equivalent to theexpressionsurrounded by parentheses90

      (expression)

    and for a range-basedfor statement of the form

      for (for-range-declaration:braced-init-list)statement

    letrange-init be equivalent tothebraced-init-list. In each case,aA range-based for statement is equivalentto

      {  auto && __range =range-initfor-range-initializer;    for ( auto __begin = begin-expr,               __end = end-expr;          __begin != __end;          ++__begin ) {for-range-declaration = *__begin;statement    }  }

    where

    • if thefor-range-initializer is anexpression, it is regarded as if it were surroundedby parentheses (so that a comma operator cannot bereinterpreted as delimitingtwoinit-declarators);

    • __range,__begin,and__end are variables defined for expositiononly,; and

    • _RangeT is the type of the expression,and

    • begin-expr andend-expr are determined asfollows:

      • if_RangeTthefor-range-initializer is anexpressionof array typeR,begin-exprandend-expr are__range and__range +__bound, respectively, where__bound is thearraybound. If_RangeTRis an array of unknown size or an array of incomplete type,the program is ill-formed;

      • if_RangeTthefor-range-initializer isaan expression of class typeC,theunqualified-idsbegin andendare looked up in the scope ofclass_RangeTC as if by class member access lookup(_N4868_.6.5.6 [basic.lookup.classref]), and if either (or both) findsat least one declaration,begin-exprandend-expr are__range.begin() and__range.end(),respectively;

      • otherwise,begin-expr andend-expr arebegin(__range) andend(__range),respectively, wherebegin andend arelooked up in the associated namespaces(6.5.4 [basic.lookup.argdep]). [Note: Ordinaryunqualified lookup (6.5.3 [basic.lookup.unqual]) is notperformed. —end note]

  6. Change the grammar of 8.8 [stmt.jump] paragraph 1as follows:

    • jump-statement:
        break ;
        continue ;
        returnexpressionexpr-or-braced-init-listopt;
        returnbraced-init-list;
        gotoidentifier;
  7. Change 8.8.4 [stmt.return] paragraph 2 as follows:

  8. Theexpressionorbraced-init-listexpr-or-braced-init-listof areturn statement is called its operand. Areturn statement...
  9. Change 12.4.5 [over.sub] paragraph 1 as follows:

  10. operator[] shall be a non-static member function withexactly one parameter. It implements the subscriptingsyntax

      postfix-expression[expressionexpr-or-braced-init-list]

    or

      postfix-expression[braced-init-list]

    Thus, a subscripting expression...

msg3523 (view)
Date: 2012-09-24.00:00:00

It would be helpful to have a single grammar term forexpression andbraced-init-list, which often occurtogether in the text. In particular, 8.6.5 [stmt.ranged] paragraph 1allows both, but the description of__RangeTrefers only to theexpression case; such errors would be lesslikely if the common term were available.

History
DateUserActionArgs
2017-02-06 00:00:00adminsetstatus: dr -> cd4
2015-11-10 00:00:00adminsetmessages: +msg6070
2015-11-10 00:00:00adminsetstatus: ready -> dr
2015-05-25 00:00:00adminsetmessages: +msg5451
2015-05-25 00:00:00adminsetstatus: drafting -> ready
2011-03-25 00:00:00admincreate

[8]ページ先頭

©2009-2026 Movatter.jp