Skip to content

Commit b60e972

Browse files
authored
ImportC: add EnumBaseType to enums (#3188)
1 parent f5a3ca8 commit b60e972

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

spec/importc.dd

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,28 @@ $(H2 $(LNAME2 extensions, Extensions))
236236
$(P Functions for which the function body is present can
237237
be inlined by ImportC as well as by the D code that calls them.)
238238

239+
$(H3 $(LNAME2 enumbasetype, Enum Base Types))
240+
241+
$(P Enums are extended with an optional $(I EnumBaseType):)
242+
243+
$(GRAMMAR
244+
$(GNAME EnumDeclaration):
245+
$(D enum) $(GLINK Identifier) $(D :) $(GLINK EnumBaseType) $(GLINK EnumBody)
246+
247+
$(GNAME EnumBaseType):
248+
$(GLINK Type)
249+
)
250+
251+
$(P which, when supplied, causes the enum members to be implicitly cast to the
252+
$(I EnumBaseType).
253+
)
254+
255+
$(CCODE
256+
enum S : byte { A };
257+
_Static_assert(sizeof(A) == 1, "A should be size 1");
258+
)
259+
260+
239261
$(H3 $(LNAME2 register, Register Storage Class))
240262

241263
$(P Objects with `register` storage class are treated as `auto` declarations.)

0 commit comments

Comments
 (0)