Files
c3c/test/test_suite/compile_time/ct_for.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

33 lines
729 B
Plaintext

// #target: macos-x64
module test;
extern fn void printf(char*, ...);
fn void main()
{
$for var $i = 0; $i < 3; $i++:
printf("Foo %d\n", $i);
$endfor;
$for $i = 0, var $j = 100; $i < 4;:
printf("Foo %d %d\n", $i++, $j--);
$endfor;
}
/* #expect: test.ll
define void @test.main() #0 {
entry:
call void (ptr, ...) @printf(ptr @.str, i32 0)
call void (ptr, ...) @printf(ptr @.str.1, i32 1)
call void (ptr, ...) @printf(ptr @.str.2, i32 2)
call void (ptr, ...) @printf(ptr @.str.3, i32 0, i32 100)
call void (ptr, ...) @printf(ptr @.str.4, i32 1, i32 99)
call void (ptr, ...) @printf(ptr @.str.5, i32 2, i32 98)
call void (ptr, ...) @printf(ptr @.str.6, i32 3, i32 97)
ret void
}