Files
c3c/test/test_suite/compile_time/ct_enum_values.c3t
Christoffer Lerno e453e6f9ca - Add enum.from_ordinal and fault.from_ordinal
- Deprecate cast-style conversion from integer to enum.
- Make deprecation an error in test mode.
2024-12-23 15:27:59 +01:00

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
}