Files
c3c/test/test_suite/generic/generic_num.c3t
2023-01-11 18:00:08 +01:00

44 lines
1.0 KiB
C

// #target: macos-x64
module hello<Type, FOO>;
fn Type x(Type t)
{
return t * t + FOO;
}
module test;
import hello;
define xint = hello::x<int, -123>;
import std::io;
fn void main()
{
io::printfn("%d", xint(4));
}
/* #expect: test.ll
define void @test_main() #0 {
entry:
%retparam = alloca i64, align 8
%varargslots = alloca [1 x %variant], align 16
%taddr = alloca i32, align 4
%0 = call i32 @"hello$$int._123_x"(i32 4)
store i32 %0, ptr %taddr, align 4
%1 = insertvalue %variant undef, ptr %taddr, 0
%2 = insertvalue %variant %1, i64 ptrtoint (ptr @"ct$int" to i64), 1
%3 = getelementptr inbounds [1 x %variant], ptr %varargslots, i64 0, i64 0
store %variant %2, ptr %3, align 16
%4 = call i64 @std_io_printfn(ptr %retparam, ptr @.str, i64 2, ptr %varargslots, i64 1)
%not_err = icmp eq i64 %4, 0
br i1 %not_err, label %after_check, label %voiderr
after_check: ; preds = %entry
br label %voiderr
voiderr: ; preds = %after_check, %entry
ret void
}