Files
c3c/test/test_suite/compile_time/ct_enum_values.c3t
Christoffer Lerno 2439405e70 - $foreach "()" replaced by trailing ":" $foreach ($x, $y : $foo) -> $foreach $x, $y : $foo:
- `$for` "()" replaced by trailing ":" `$for (var $x = 0; $x < FOO; $x++)` -> `$for var $x = 0; $x < FOO; $x++:`
- `$switch` "()" replaced by trailing ":" `$switch ($Type)` -> `$switch $Type:`
- Empty `$switch` requires trailing ":" `$switch` -> `$switch:`
2025-03-04 16:13:47 +01:00

31 lines
386 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
}