mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Distinct inline can now be called if it is aliasing a function pointer.
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
module output;
|
||||
module test;
|
||||
|
||||
def FnA = fn void(int*);
|
||||
distinct FnB = FnA;
|
||||
distinct FnC = inline FnA;
|
||||
|
||||
fn void func(int*) {}
|
||||
|
||||
@@ -11,4 +12,22 @@ fn void main()
|
||||
FnB b = (FnB)&func;
|
||||
FnB b2 = &func;
|
||||
FnB b3 = fn (int* x) {};
|
||||
}
|
||||
FnC c = &func;
|
||||
c(null);
|
||||
}
|
||||
|
||||
/* #expect: test.ll
|
||||
|
||||
%a = alloca ptr, align 8
|
||||
%b = alloca ptr, align 8
|
||||
%b2 = alloca ptr, align 8
|
||||
%b3 = alloca ptr, align 8
|
||||
%c = alloca ptr, align 8
|
||||
store ptr @test.func, ptr %a, align 8
|
||||
store ptr @test.func, ptr %b, align 8
|
||||
store ptr @test.func, ptr %b2, align 8
|
||||
store ptr @"test.main$lambda1", ptr %b3, align 8
|
||||
store ptr @test.func, ptr %c, align 8
|
||||
%0 = load ptr, ptr %c, align 8
|
||||
call void %0(ptr null)
|
||||
ret void
|
||||
|
||||
16
test/test_suite/distinct/distinct_function_call.c3
Normal file
16
test/test_suite/distinct/distinct_function_call.c3
Normal file
@@ -0,0 +1,16 @@
|
||||
def Abc = fn void();
|
||||
distinct Foo = inline Abc;
|
||||
struct Bar
|
||||
{
|
||||
inline Abc a;
|
||||
}
|
||||
fn void test()
|
||||
{
|
||||
}
|
||||
fn void main()
|
||||
{
|
||||
Foo f = &test;
|
||||
Bar b = { &test };
|
||||
f();
|
||||
b(); // #error: may be invoked
|
||||
}
|
||||
Reference in New Issue
Block a user