From Jason Turner

[stmt.return.coroutine]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpn6dnuj9q/{from.md → to.md} +10 -9
tmp/tmpn6dnuj9q/{from.md → to.md} RENAMED
@@ -1,26 +1,26 @@
1
  ### The `co_return` statement <a id="stmt.return.coroutine">[[stmt.return.coroutine]]</a>
2
 
3
  ``` bnf
4
  coroutine-return-statement:
5
- 'co_return' expr-or-braced-init-listₒₚₜ ';'
6
  ```
7
 
8
- A coroutine returns to its caller or resumer [[dcl.fct.def.coroutine]]
9
- by the `co_return` statement or when suspended [[expr.await]]. A
10
- coroutine shall not enclose a `return` statement [[stmt.return]].
11
 
12
  [*Note 1*: For this determination, it is irrelevant whether the
13
  `return` statement is enclosed by a discarded statement
14
  [[stmt.if]]. — *end note*]
15
 
16
  The *expr-or-braced-init-list* of a `co_return` statement is called its
17
  operand. Let *p* be an lvalue naming the coroutine promise object
18
  [[dcl.fct.def.coroutine]]. A `co_return` statement is equivalent to:
19
 
20
  ``` bnf
21
- '{' S';' 'goto' final-suspend';' '}'
22
  ```
23
 
24
  where *`final-suspend`* is the exposition-only label defined in
25
  [[dcl.fct.def.coroutine]] and *S* is defined as follows:
26
 
@@ -29,10 +29,11 @@ where *`final-suspend`* is the exposition-only label defined in
29
  expression *S* shall be a prvalue of type `void`.
30
  - Otherwise, *S* is the *compound-statement* `{` *expression*ₒₚₜ `;`
31
  *p*`.return_void()``; }`. The expression *p*`.return_void()` shall be
32
  a prvalue of type `void`.
33
 
34
- If *p*`.return_void()` is a valid expression, flowing off the end of a
35
- coroutine’s *function-body* is equivalent to a `co_return` with no
36
- operand; otherwise flowing off the end of a coroutine’s *function-body*
37
- results in undefined behavior.
 
38
 
 
1
  ### The `co_return` statement <a id="stmt.return.coroutine">[[stmt.return.coroutine]]</a>
2
 
3
  ``` bnf
4
  coroutine-return-statement:
5
+ co_return expr-or-braced-init-listₒₚₜ ';'
6
  ```
7
 
8
+ A `co_return` statement transfers control to the caller or resumer of a
9
+ coroutine [[dcl.fct.def.coroutine]]. A coroutine shall not enclose a
10
+ `return` statement [[stmt.return]].
11
 
12
  [*Note 1*: For this determination, it is irrelevant whether the
13
  `return` statement is enclosed by a discarded statement
14
  [[stmt.if]]. — *end note*]
15
 
16
  The *expr-or-braced-init-list* of a `co_return` statement is called its
17
  operand. Let *p* be an lvalue naming the coroutine promise object
18
  [[dcl.fct.def.coroutine]]. A `co_return` statement is equivalent to:
19
 
20
  ``` bnf
21
+ '{' S';' goto final-suspend';' '}'
22
  ```
23
 
24
  where *`final-suspend`* is the exposition-only label defined in
25
  [[dcl.fct.def.coroutine]] and *S* is defined as follows:
26
 
 
29
  expression *S* shall be a prvalue of type `void`.
30
  - Otherwise, *S* is the *compound-statement* `{` *expression*ₒₚₜ `;`
31
  *p*`.return_void()``; }`. The expression *p*`.return_void()` shall be
32
  a prvalue of type `void`.
33
 
34
+ If a search for the name `return_void` in the scope of the promise type
35
+ finds any declarations, flowing off the end of a coroutine’s
36
+ *function-body* is equivalent to a `co_return` with no operand;
37
+ otherwise flowing off the end of a coroutine’s *function-body* results
38
+ in undefined behavior.
39