Skip to content

Commit cd22832

Browse files
WalterBrightdlang-bot
authored andcommitted
switch expression and integral promotions
1 parent 52ce838 commit cd22832

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

spec/statement.dd

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,9 +1106,17 @@ $(GNAME StatementNoCaseNoDefault):
11061106
$(GLINK ScopeBlockStatement)
11071107
)
11081108

1109-
$(P $(EXPRESSION) is evaluated. The result type T must be
1110-
of integral type or $(CODE char[]), $(CODE wchar[]) or $(CODE dchar[]).
1111-
The result is
1109+
$(P $(I Expression) is evaluated.
1110+
If the type of the $(I Expression) is an enum,
1111+
it is repeatedly converted
1112+
to its $(GLINK2 enum, EnumBaseType) until it isn't. Then,
1113+
if the type is of integral type,
1114+
the $(I Expression) undergoes $(DDSUBLINK spec/type, integer-promotions, Integer Promotions).
1115+
Then, the type of the $(I Expression) must be either of integral type or
1116+
a static or dynamic array of $(CODE char), $(CODE wchar), or $(CODE dchar).
1117+
)
1118+
1119+
$(P The result is
11121120
compared against each of the case expressions. If there is
11131121
a match, the corresponding case statement is transferred to.
11141122
)

0 commit comments

Comments
 (0)