Make errors usable from other units. Order subarray elements correctly. Correct subarray -> pointer cast. Prevent unwrapping of catch in switch.

This commit is contained in:
Christoffer Lerno
2021-08-31 18:12:30 +02:00
parent 2ff5acc2a1
commit bb9e84d329
16 changed files with 820 additions and 151 deletions

View File

@@ -0,0 +1,37 @@
// #target: x64-darwin
module demo;
define Callback = func int(char* text, int value);
func int my_callback(char* text, int value)
{
return 0;
}
Callback cb = &my_callback;
func void main()
{
int result = cb("demo", 123);
// ..
}
// #expect: demo.ll
define i32 @demo.my_callback(i8* %0, i32 %1) #0 {
entry:
%text = alloca i8*, align 8
%value = alloca i32, align 4
store i8* %0, i8** %text, align 8
store i32 %1, i32* %value, align 4
ret i32 0
}
define void @main() #0 {
entry:
%result = alloca i32, align 4
%0 = load i32 (i8*, i32)*, i32 (i8*, i32)** @demo.cb, align 8
%1 = call i32 %0(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i32 123)
store i32 %1, i32* %result, align 4
ret void
}