Files
c3c/test/test_suite/methods/enum_distinct_err_methods.c3t
Christoffer Lerno 5a2fe4c9d9 Fix to macro codegen.
2023-07-19 01:34:50 +02:00

90 lines
1.7 KiB
C

// #target: macos-x64
module foo;
import std::io;
fault Foo
{
X
}
def Bar = distinct int;
enum MyEnum
{
A,
B
}
fn void Foo.hello(Foo *f)
{
io::printn("Hello from Foo");
}
fn void Bar.hello(Bar *b)
{
io::printn("Hello from Bar");
}
fn void MyEnum.hello(MyEnum *myenum)
{
io::printn("Hello from MyEnum");
}
fn int main()
{
Foo f;
Bar b;
MyEnum a = MyEnum.A;
f.hello();
b.hello();
a.hello();
return 0;
}
/* #expect: foo.ll
define void @foo.Foo.hello(ptr %0) #0 {
entry:
%retparam = alloca i64, align 8
%result = alloca %File, align 8
%1 = call ptr @std.io.stdout()
store ptr %1, ptr %result, align 8
%2 = load ptr, ptr %result, align 8
%3 = call i64 @std.io.File.printn(ptr %retparam, ptr %2, ptr @.str, i64 14)
ret void
}
define void @foo.Bar.hello(ptr %0) #0 {
entry:
%retparam = alloca i64, align 8
%result = alloca %File, align 8
%1 = call ptr @std.io.stdout()
store ptr %1, ptr %result, align 8
%2 = load ptr, ptr %result, align 8
%3 = call i64 @std.io.File.printn(ptr %retparam, ptr %2, ptr @.str.1, i64 14)
ret void
}
define void @foo.MyEnum.hello(ptr %0) #0 {
entry:
%retparam = alloca i64, align 8
%result = alloca %File, align 8
%1 = call ptr @std.io.stdout()
store ptr %1, ptr %result, align 8
%2 = load ptr, ptr %result, align 8
%3 = call i64 @std.io.File.printn(ptr %retparam, ptr %2, ptr @.str.2, i64 17)
ret void
}
define i32 @main() #0 {
entry:
%f = alloca i64, align 8
%b = alloca i32, align 4
%a = alloca i32, align 4
store i64 0, ptr %f, align 8
store i32 0, ptr %b, align 4
store i32 0, ptr %a, align 4
call void @foo.Foo.hello(ptr %f)
call void @foo.Bar.hello(ptr %b)
call void @foo.MyEnum.hello(ptr %a)
ret i32 0
}