mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00

* Mark C enums as semantic2done to prevent segfaults in final switch * Added corresponding test case
23 lines
426 B
D
23 lines
426 B
D
// EXTRA_FILES: imports/cstuff3.c
|
|
import imports.cstuff3;
|
|
|
|
static assert(squared(4) == 16);
|
|
|
|
/* test case for issue #21094 */
|
|
string enum_to_str(E)(E v) if (is(E == enum))
|
|
{
|
|
final switch (v) with(E)
|
|
{
|
|
static foreach (m; __traits(allMembers, E))
|
|
{
|
|
case mixin(m):
|
|
return m;
|
|
}
|
|
}
|
|
}
|
|
|
|
void testEnumSwitch()
|
|
{
|
|
auto str = enum_to_str(UPNG_EOK);
|
|
assert(str == "UPNG_EOK");
|
|
}
|