From Jason Turner

[stmt.select]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpbw9kwa2s/{from.md → to.md} +19 -18
tmp/tmpbw9kwa2s/{from.md → to.md} RENAMED
@@ -41,16 +41,17 @@ if (x) {
41
 
42
  Thus after the `if` statement, `i` is no longer in scope.
43
 
44
  The rules for *condition*s apply both to *selection-statement*s and to
45
  the `for` and `while` statements ([[stmt.iter]]). The *declarator*
46
- shall not specify a function or an array. If the `auto` appears in the ,
47
- the type of the identifier being declared is deduced from the
48
- initializer as described in  [[dcl.spec.auto]].
 
49
 
50
  A name introduced by a declaration in a *condition* (either introduced
51
- by the *type-specifier-seq* or the *declarator* of the condition) is in
52
  scope from its point of declaration until the end of the substatements
53
  controlled by the condition. If the name is re-declared in the outermost
54
  block of a substatement controlled by the condition, the declaration
55
  that re-declares the name is ill-formed.
56
 
@@ -86,37 +87,37 @@ shall be either a *type-specifier* or `constexpr`.
86
  ### The `if` statement <a id="stmt.if">[[stmt.if]]</a>
87
 
88
  If the condition ([[stmt.select]]) yields `true` the first substatement
89
  is executed. If the `else` part of the selection statement is present
90
  and the condition yields `false`, the second substatement is executed.
91
- In the second form of `if` statement (the one including `else`), if the
92
- first substatement is also an `if` statement then that inner `if`
93
- statement shall contain an `else` part.[^1]
 
 
94
 
95
  ### The `switch` statement <a id="stmt.switch">[[stmt.switch]]</a>
96
 
97
  The `switch` statement causes control to be transferred to one of
98
  several statements depending on the value of a condition.
99
 
100
- The condition shall be of integral type, enumeration type, or of a class
101
- type for which a single non-explicit conversion function to integral or
102
- enumeration type exists ([[class.conv]]). If the condition is of class
103
- type, the condition is converted by calling that conversion function,
104
- and the result of the conversion is used in place of the original
105
- condition for the remainder of this section. Integral promotions are
106
- performed. Any statement within the `switch` statement can be labeled
107
- with one or more case labels as follows:
108
 
109
  ``` bnf
110
  'case' constant-expression ':'
111
  ```
112
 
113
  where the *constant-expression* shall be a converted constant
114
- expression ([[expr.const]]) of the promoted type of the switch
115
  condition. No two of the case constants in the same switch shall have
116
- the same value after conversion to the promoted type of the switch
117
- condition.
118
 
119
  There shall be at most one label of the form
120
 
121
  ``` cpp
122
  default :
 
41
 
42
  Thus after the `if` statement, `i` is no longer in scope.
43
 
44
  The rules for *condition*s apply both to *selection-statement*s and to
45
  the `for` and `while` statements ([[stmt.iter]]). The *declarator*
46
+ shall not specify a function or an array. The *decl-specifier-seq* shall
47
+ not define a class or enumeration. If the `auto` appears in the , the
48
+ type of the identifier being declared is deduced from the initializer as
49
+ described in  [[dcl.spec.auto]].
50
 
51
  A name introduced by a declaration in a *condition* (either introduced
52
+ by the *decl-specifier-seq* or the *declarator* of the condition) is in
53
  scope from its point of declaration until the end of the substatements
54
  controlled by the condition. If the name is re-declared in the outermost
55
  block of a substatement controlled by the condition, the declaration
56
  that re-declares the name is ill-formed.
57
 
 
87
  ### The `if` statement <a id="stmt.if">[[stmt.if]]</a>
88
 
89
  If the condition ([[stmt.select]]) yields `true` the first substatement
90
  is executed. If the `else` part of the selection statement is present
91
  and the condition yields `false`, the second substatement is executed.
92
+ If the first substatement is reached via a label, the condition is not
93
+ evaluated and the second substatement is not executed. In the second
94
+ form of `if` statement (the one including `else`), if the first
95
+ substatement is also an `if` statement then that inner `if` statement
96
+ shall contain an `else` part.[^1]
97
 
98
  ### The `switch` statement <a id="stmt.switch">[[stmt.switch]]</a>
99
 
100
  The `switch` statement causes control to be transferred to one of
101
  several statements depending on the value of a condition.
102
 
103
+ The condition shall be of integral type, enumeration type, or class
104
+ type. If of class type, the condition is contextually implicitly
105
+ converted (Clause  [[conv]]) to an integral or enumeration type. If the
106
+ (possibly converted) type is subject to integral promotions (
107
+ [[conv.prom]]), the condition is converted to the promoted type. Any
108
+ statement within the `switch` statement can be labeled with one or more
109
+ case labels as follows:
 
110
 
111
  ``` bnf
112
  'case' constant-expression ':'
113
  ```
114
 
115
  where the *constant-expression* shall be a converted constant
116
+ expression ([[expr.const]]) of the adjusted type of the switch
117
  condition. No two of the case constants in the same switch shall have
118
+ the same value after conversion.
 
119
 
120
  There shall be at most one label of the form
121
 
122
  ``` cpp
123
  default :