Files
c3c/test/test_suite/errors/macro_err2.c3t
Christoffer Lerno 5c77c9a754 - Change distinct -> typedef.
- Order of attribute declaration is changed for `alias`.
- Added `LANGUAGE_DEV_VERSION` env constant.
- Rename `anyfault` -> `fault`.
- Changed `fault` -> `faultdef`.
- Added `attrdef` instead of `alias` for attribute aliases.
2025-03-15 20:10:47 +01:00

61 lines
1.5 KiB
Plaintext

// #target: macos-x64
module test;
import libc;
faultdef FOO;
fn int? abc()
{
return 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(ptr %0) #0 {
entry:
ret i64 ptrtoint (ptr @test.FOO to i64)
}
define void @test.main() #0 {
entry:
%blockret = alloca i32, align 4
%retparam = alloca i32, align 4
%0 = call i64 @test.abc(ptr %retparam)
%not_err = icmp eq i64 %0, 0
%1 = call i1 @llvm.expect.i1(i1 %not_err, i1 true)
br i1 %1, label %after_check, label %opt_block_cleanup
after_check: ; preds = %entry
%2 = load i32, ptr %retparam, align 4
store i32 %2, ptr %blockret, align 4
%3 = call i32 (ptr, ...) @printf(ptr @.str.1)
br label %expr_block.exit
opt_block_cleanup: ; preds = %entry
%4 = call i32 (ptr, ...) @printf(ptr @.str.2)
br label %else_block
expr_block.exit: ; preds = %after_check
%5 = load i32, ptr %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 [ %5, %expr_block.exit ], [ 2, %else_block ]
%6 = call i32 (ptr, ...) @printf(ptr @.str, i32 %val)
%7 = call i32 (ptr, ...) @printf(ptr @.str.3)
ret void
}