From Jason Turner

[stmt.switch]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpmcpw_cfa/{from.md → to.md} +26 -19
tmp/tmpmcpw_cfa/{from.md → to.md} RENAMED
@@ -3,24 +3,24 @@
3
  The `switch` statement causes control to be transferred to one of
4
  several statements depending on the value of a condition.
5
 
6
  The condition shall be of integral type, enumeration type, or class
7
  type. If of class type, the condition is contextually implicitly
8
- converted (Clause  [[conv]]) to an integral or enumeration type. If the
9
- (possibly converted) type is subject to integral promotions (
10
- [[conv.prom]]), the condition is converted to the promoted type. Any
11
- statement within the `switch` statement can be labeled with one or more
12
- case labels as follows:
13
 
14
  ``` bnf
15
- 'case' constant-expression ':'
16
  ```
17
 
18
- where the *constant-expression* shall be a converted constant
19
- expression ([[expr.const]]) of the adjusted type of the switch
20
- condition. No two of the case constants in the same switch shall have
21
- the same value after conversion.
22
 
23
  There shall be at most one label of the form
24
 
25
  ``` cpp
26
  default :
@@ -29,34 +29,41 @@ default :
29
  within a `switch` statement.
30
 
31
  Switch statements can be nested; a `case` or `default` label is
32
  associated with the smallest switch enclosing it.
33
 
34
- When the `switch` statement is executed, its condition is evaluated and
35
- compared with each case constant. If one of the case constants is equal
36
- to the value of the condition, control is passed to the statement
37
- following the matched case label. If no case constant matches the
38
- condition, and if there is a `default` label, control passes to the
39
- statement labeled by the default label. If no case matches and if there
40
- is no `default` then none of the statements in the switch is executed.
41
 
42
  `case` and `default` labels in themselves do not alter the flow of
43
  control, which continues unimpeded across such labels. To exit from a
44
- switch, see `break`,  [[stmt.break]].
45
 
46
  [*Note 1*: Usually, the substatement that is the subject of a switch is
47
  compound and `case` and `default` labels appear on the top-level
48
  statements contained within the (compound) substatement, but this is not
49
  required. Declarations can appear in the substatement of a `switch`
50
  statement. — *end note*]
51
 
52
  A `switch` statement of the form
53
 
54
  ``` bnf
55
- 'switch (' init-statement condition ')' statement
56
  ```
57
 
58
  is equivalent to
59
 
 
 
 
 
 
 
 
60
  except that names declared in the *init-statement* are in the same
61
  declarative region as those declared in the *condition*.
62
 
 
3
  The `switch` statement causes control to be transferred to one of
4
  several statements depending on the value of a condition.
5
 
6
  The condition shall be of integral type, enumeration type, or class
7
  type. If of class type, the condition is contextually implicitly
8
+ converted [[conv]] to an integral or enumeration type. If the (possibly
9
+ converted) type is subject to integral promotions [[conv.prom]], the
10
+ condition is converted to the promoted type. Any statement within the
11
+ `switch` statement can be labeled with one or more case labels as
12
+ follows:
13
 
14
  ``` bnf
15
+ case constant-expression ':'
16
  ```
17
 
18
+ where the *constant-expression* shall be a converted constant expression
19
+ [[expr.const]] of the adjusted type of the switch condition. No two of
20
+ the case constants in the same switch shall have the same value after
21
+ conversion.
22
 
23
  There shall be at most one label of the form
24
 
25
  ``` cpp
26
  default :
 
29
  within a `switch` statement.
30
 
31
  Switch statements can be nested; a `case` or `default` label is
32
  associated with the smallest switch enclosing it.
33
 
34
+ When the `switch` statement is executed, its condition is evaluated. If
35
+ one of the case constants has the same value as the condition, control
36
+ is passed to the statement following the matched case label. If no case
37
+ constant matches the condition, and if there is a `default` label,
38
+ control passes to the statement labeled by the default label. If no case
39
+ matches and if there is no `default` then none of the statements in the
40
+ switch is executed.
41
 
42
  `case` and `default` labels in themselves do not alter the flow of
43
  control, which continues unimpeded across such labels. To exit from a
44
+ switch, see `break`, [[stmt.break]].
45
 
46
  [*Note 1*: Usually, the substatement that is the subject of a switch is
47
  compound and `case` and `default` labels appear on the top-level
48
  statements contained within the (compound) substatement, but this is not
49
  required. Declarations can appear in the substatement of a `switch`
50
  statement. — *end note*]
51
 
52
  A `switch` statement of the form
53
 
54
  ``` bnf
55
+ switch '(' init-statement condition ')' statement
56
  ```
57
 
58
  is equivalent to
59
 
60
+ ``` bnf
61
+ '{'
62
+ init-statement
63
+ switch '(' condition ')' statement
64
+ '}'
65
+ ```
66
+
67
  except that names declared in the *init-statement* are in the same
68
  declarative region as those declared in the *condition*.
69