mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
- Deprecate cast-style conversion from integer to enum. - Make deprecation an error in test mode.
31 lines
387 B
Plaintext
31 lines
387 B
Plaintext
// #target: macos-x64
|
|
module test;
|
|
enum Vehicles
|
|
{
|
|
CAR,
|
|
PLANE
|
|
}
|
|
|
|
macro elements($Type)
|
|
{
|
|
int x;
|
|
$foreach ($x : $Type.values)
|
|
x = $x.ordinal;
|
|
$endforeach;
|
|
}
|
|
|
|
fn void main()
|
|
{
|
|
elements(Vehicles);
|
|
}
|
|
|
|
/* #expect: test.ll
|
|
|
|
entry:
|
|
%x = alloca i32, align 4
|
|
store i32 0, ptr %x, align 4
|
|
store i32 0, ptr %x, align 4
|
|
store i32 1, ptr %x, align 4
|
|
ret void
|
|
}
|