mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
58 lines
1.7 KiB
C
58 lines
1.7 KiB
C
// #target: macos-x64
|
|
module test;
|
|
fault Tester { FOO }
|
|
|
|
fn int! abc()
|
|
{
|
|
return Tester.FOO!;
|
|
}
|
|
macro test()
|
|
{
|
|
defer libc::printf("Test2\n");
|
|
return abc();
|
|
}
|
|
|
|
fn void main()
|
|
{
|
|
defer libc::printf("Test1\n");
|
|
libc::printf("%d\n", test() ?? 2);
|
|
}
|
|
|
|
/* #expect: test.ll
|
|
|
|
define i64 @test.abc(i32* %0) #0 {
|
|
entry:
|
|
ret i64 ptrtoint ([1 x i8*]* @"test.Tester$elements" to i64)
|
|
}
|
|
|
|
define void @test.main() #0 {
|
|
entry:
|
|
%blockret = alloca i32, align 4
|
|
%retparam = alloca i32, align 4
|
|
%0 = call i64 @test.abc(i32* %retparam)
|
|
%not_err = icmp eq i64 %0, 0
|
|
br i1 %not_err, label %after.errcheck, label %opt_block_cleanup
|
|
|
|
after.errcheck: ; preds = %entry
|
|
%1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0))
|
|
%2 = load i32, i32* %retparam, align 4
|
|
store i32 %2, i32* %blockret, align 4
|
|
br label %expr_block.exit
|
|
|
|
opt_block_cleanup: ; preds = %entry
|
|
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0))
|
|
br label %else_block
|
|
|
|
expr_block.exit: ; preds = %after.errcheck
|
|
%4 = load i32, i32* %blockret, align 4
|
|
br label %phi_block
|
|
|
|
else_block: ; preds = %opt_block_cleanup
|
|
br label %phi_block
|
|
|
|
phi_block: ; preds = %else_block, %expr_block.exit
|
|
%val = phi i32 [ %4, %expr_block.exit ], [ 2, %else_block ]
|
|
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %val)
|
|
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0))
|
|
ret void
|
|
}
|