Files
c3c/test/test_suite/methods/enum_distinct_err_methods.c3t

75 lines
1.5 KiB
C

// #target: x64-darwin
module foo;
import std::io;
errtype Foo
{
X
}
define Bar = distinct int;
enum MyEnum
{
A,
B
}
func void Foo.hello(Foo *f)
{
io::println("Hello from Foo");
}
func void Bar.hello(Bar *b)
{
io::println("Hello from Bar");
}
func void MyEnum.hello(MyEnum *myenum)
{
io::println("Hello from MyEnum");
}
func void main()
{
Foo f;
Bar b;
MyEnum a = MyEnum.A;
f.hello();
b.hello();
a.hello();
}
// #expect: foo.ll
define void @foo.Foo__hello(i64* %0)
%f = alloca i64*, align 8
store i64* %0, i64** %f, align 8
%1 = call i32 @"std::io.println"(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i32 0, i32 0))
ret void
define void @foo.Bar__hello(i32* %0)
%b = alloca i32*, align 8
store i32* %0, i32** %b, align 8
%1 = call i32 @"std::io.println"(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i32 0, i32 0))
ret void
define void @foo.MyEnum__hello(i32* %0)
%myenum = alloca i32*, align 8
store i32* %0, i32** %myenum, align 8
%1 = call i32 @"std::io.println"(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i32 0, i32 0))
ret void
define void @main()
entry:
%f = alloca i64, align 8
%b = alloca i32, align 4
%a = alloca i32, align 4
store i64 0, i64* %f, align 8
store i32 0, i32* %b, align 4
store i32 0, i32* %a, align 4
call void @foo.Foo__hello(i64* %f)
call void @foo.Bar__hello(i32* %b)
call void @foo.MyEnum__hello(i32* %a)
ret void