@@ -71,36 +71,37 @@ $(H2 $(LNAME2 named_enums, Named Enums))
71
71
72
72
73
73
$(P If the $(I EnumBaseType) is not explicitly set, and the first
74
- $(I EnumMember) has an $(ASSIGNEXPRESSION) , it is set to the type of that
75
- $(ASSIGNEXPRESSION) . Otherwise, it defaults to
74
+ $(I EnumMember) has an *AssignExpression* , it is set to the type of that
75
+ *AssignExpression* . Otherwise, it defaults to
76
76
type $(CODE int).)
77
77
78
78
$(P Named enum members may not have individual $(I Type)s.
79
79
)
80
80
81
-
82
81
$(P A named enum member can be implicitly cast to its $(GLINK EnumBaseType),
83
82
but $(I EnumBaseType) types
84
83
cannot be implicitly cast to an enum type.
85
84
)
86
85
87
- $(P The value of an $(GLINK EnumMember) is given by its $(ASSIGNEXPRESSION) .
88
- If there is no $(ASSIGNEXPRESSION) and it is the first $(I EnumMember),
86
+ $(P The value of an $(GLINK EnumMember) is given by its *AssignExpression* if present .
87
+ If there is no *AssignExpression* and it is the first $(I EnumMember),
89
88
its value is $(GLINK EnumBaseType)`.init`.
89
+ If there is no *AssignExpression* and it is not the first $(I EnumMember),
90
+ it is given the value of the previous $(I EnumMember)`+1`:)
91
+
92
+ * If the value of the previous $(I EnumMember) is $(GLINK EnumBaseType)`.max`,
93
+ it is an error. This prevents value overflow. It is an error if the previous
94
+ member cannot be compared with *EnumBaseType*`.max` at compile-time.
95
+ * It is an error if the base type does not define a compile-time
96
+ evaluable `+1` operation.
97
+ * If the value of the previous $(I EnumMember)`+1` is the same as the
98
+ value of the previous $(I EnumMember), it is an error. (This can happen
99
+ with floating point types).
100
+
101
+ $(P All $(I EnumMember)s are in scope for the *AssignExpression*s.
90
102
)
91
103
92
- $(P If there is no $(ASSIGNEXPRESSION) and it is not the first $(I EnumMember),
93
- it is given the value of the previous $(I EnumMember)`+1`.
94
- If the value of the previous $(I EnumMember) is $(GLINK EnumBaseType)`.max`,
95
- it is an error.
96
- If the value of the previous $(I EnumMember)`+1` is the same as the
97
- value of the previous $(I EnumMember), it is an error. (This can happen
98
- with floating point types.)
99
- )
100
-
101
- $(P All $(I EnumMember)s are in scope for the $(ASSIGNEXPRESSION)s.
102
- )
103
-
104
+ $(SPEC_RUNNABLE_EXAMPLE_FAIL
104
105
---
105
106
enum A = 3;
106
107
enum B
@@ -120,7 +121,7 @@ enum E : C
120
121
E2 // error, C.D is C.max
121
122
}
122
123
---
123
-
124
+ )
124
125
125
126
$(P An empty enum body (For example $(CODE enum E;)) signifies an opaque
126
127
enum - the enum members are unknown.)
@@ -196,22 +197,23 @@ enum { A, B, C } // anonymous enum
196
197
$(P Enums must have at least one member.
197
198
)
198
199
199
- $(P The value of an $(I EnumMember) is given by its $(ASSIGNEXPRESSION) .
200
- If there is no $(ASSIGNEXPRESSION) and it is the first $(I EnumMember),
200
+ $(P The value of an $(I EnumMember) is given by its *AssignExpression* if present .
201
+ If there is no *AssignExpression* and it is the first $(I EnumMember),
201
202
its value is the $(CODE .init) property of the $(I EnumMember)'s type.
202
- )
203
-
204
- $(P If there is no $(ASSIGNEXPRESSION) and it is not the first $(I EnumMember),
205
- it is given the value of the previous $(I EnumMember)`+1`.
206
- If the value of the previous $(I EnumMember) is the `.max` property
207
- if the previous $(I EnumMember)'s type,
208
- it is an error.
209
- If the value of the previous $(I EnumMember)`+1` is the same as the
210
- value of the previous $(I EnumMember), it is an error. (This can happen
211
- with floating point types.)
212
- )
213
-
214
- $(P All $(I EnumMember)s are in scope for the $(ASSIGNEXPRESSION)s.
203
+ If there is no *AssignExpression* and it is not the first $(I EnumMember),
204
+ it is given the value of the previous $(I EnumMember)`+1`:)
205
+
206
+ * If the value of the previous $(I EnumMember) is the `.max` property
207
+ of the previous $(I EnumMember)'s type, it is an error.
208
+ This prevents value overflow. It is an error if the previous
209
+ member cannot be compared with its `.max` property at compile-time.
210
+ * It is an error if the type of the previous member does not define a compile-time
211
+ evaluable `+1` operation.
212
+ * If the value of the previous $(I EnumMember)`+1` is the same as the
213
+ value of the previous $(I EnumMember), it is an error. (This can happen
214
+ with floating point types).
215
+
216
+ $(P All $(I EnumMember)s are in scope for the *AssignExpression*s.
215
217
)
216
218
217
219
------
0 commit comments