mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Upgrade of mingw in CI. Fix problems using reflection on interface types #1203. Improved debug information on defer. $foreach doesn't create an implicit syntactic scope. Error if `@if` depends on `@if`. Updated Linux stacktrace. Fix of default argument stacktrace. Allow linking libraries directly by file path. Improve inlining warning messages. Added `index_of_char_from`. Compiler crash using enum nameof from different module #1205. Removed unused fields in find_msvc. Use vswhere to find msvc. Update tests for LLVM 19
42 lines
1.0 KiB
Plaintext
42 lines
1.0 KiB
Plaintext
// #target: macos-x64
|
|
module test;
|
|
import std::io;
|
|
|
|
fn void test(int x)
|
|
{
|
|
$typeof(&$$FUNCTION) ptr = &$$FUNCTION;
|
|
io::printfn("%d", x);
|
|
if (x > 0) ptr(x - 1);
|
|
}
|
|
|
|
fn void main()
|
|
{
|
|
test(10);
|
|
}
|
|
|
|
/* #expect: test.ll
|
|
|
|
define void @test.test(i32 %0) #0 {
|
|
entry:
|
|
%ptr = alloca ptr, align 8
|
|
%varargslots = alloca [1 x %any], align 16
|
|
%taddr = alloca i32, align 4
|
|
%retparam = alloca i64, align 8
|
|
store ptr @test.test, ptr %ptr, align 8
|
|
store i32 %0, ptr %taddr, align 4
|
|
%1 = insertvalue %any undef, ptr %taddr, 0
|
|
%2 = insertvalue %any %1, i64 ptrtoint (ptr @"$ct.int" to i64), 1
|
|
store %any %2, ptr %varargslots, align 16
|
|
%3 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 2, ptr %varargslots, i64 1)
|
|
%gt = icmp sgt i32 %0, 0
|
|
br i1 %gt, label %if.then, label %if.exit
|
|
|
|
if.then: ; preds = %entry
|
|
%4 = load ptr, ptr %ptr, align 8
|
|
%sub = sub i32 %0, 1
|
|
call void %4(i32 %sub)
|
|
br label %if.exit
|
|
|
|
if.exit: ; preds = %if.then, %entry
|
|
ret void
|
|
} |