mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
58 lines
954 B
C
58 lines
954 B
C
module test;
|
|
import std::io;
|
|
import test2;
|
|
|
|
fn void test(int a = test2::bar(), int b = test2::foo())
|
|
{
|
|
io::printf("%d %d\n", a, b);
|
|
}
|
|
|
|
module test2;
|
|
|
|
fn int foo()
|
|
{
|
|
static int x = 0;
|
|
return ++x;
|
|
}
|
|
|
|
macro int bar()
|
|
{
|
|
static int x = 0;
|
|
return ++x;
|
|
}
|
|
|
|
module test3;
|
|
import test;
|
|
import std::io;
|
|
|
|
fn void main()
|
|
{
|
|
test::test(1, 2);
|
|
test::test(.a = 3);
|
|
test::test(1, .b = 32);
|
|
test::test();
|
|
test::test();
|
|
}
|
|
|
|
// #expect: test3.ll
|
|
|
|
entry:
|
|
call void @test_test(i32 1, i32 2)
|
|
%0 = call i32 @test2_foo()
|
|
call void @test_test(i32 3, i32 %0)
|
|
call void @test_test(i32 1, i32 32)
|
|
%1 = load i32, ptr @"main$x", align 4
|
|
%add = add i32 %1, 1
|
|
store i32 %add, ptr @"main$x", align 4
|
|
%2 = call i32 @test2_foo()
|
|
call void @test_test(i32 %add, i32 %2)
|
|
%3 = load i32, ptr @"main$x.1", align 4
|
|
%add1 = add i32 %3, 1
|
|
store i32 %add1, ptr @"main$x.1", align 4
|
|
%4 = call i32 @test2_foo()
|
|
call void @test_test(i32 %add1, i32 %4)
|
|
ret void
|
|
}
|
|
|
|
|