Additional #2210 fixes.

This commit is contained in:
Christoffer Lerno
2025-06-16 22:56:34 +02:00
parent 3ce15bd7af
commit f0bd93d1f0
4 changed files with 143 additions and 4 deletions

View File

@@ -0,0 +1,45 @@
// #target: windows-x64
module test;
struct Window
{
char* content;
}
macro Window @content($content = {},)
{
$switch:
$case $defined((char*) $content):
return { .content = $content, };
$default:
unreachable();
$endswitch
}
fn void main()
{
Window[] windows = {
@content($content: { "foo" },
),
};
}
/* #expect: test.ll
define void @test.main() #0 {
entry:
%windows = alloca %"Window[]", align 8
%literal = alloca [1 x %Window], align 8
%blockret = alloca %Window, align 8
unreachable
after_macro: ; No predecessors!
unreachable
after_macro1: ; No predecessors!
store %Window poison, ptr %literal, align 8
%0 = insertvalue %"Window[]" undef, ptr %literal, 0
%1 = insertvalue %"Window[]" %0, i64 1, 1
store %"Window[]" %1, ptr %windows, align 8
ret void
}

View File

@@ -0,0 +1,24 @@
// #target: windows-x64
module test;
fn void main()
{
int[] kaput = { unreachable() };
}
/* #expect: test.ll
define void @test.main() #0 {
entry:
%kaput = alloca %"int[]", align 8
%literal = alloca [1 x i32], align 4
%blockret = alloca i32, align 4
unreachable
after_macro: ; No predecessors!
store i32 poison, ptr %literal, align 4
%0 = insertvalue %"int[]" undef, ptr %literal, 0
%1 = insertvalue %"int[]" %0, i64 1, 1
store %"int[]" %1, ptr %kaput, align 8
ret void
}

View File

@@ -0,0 +1,69 @@
// #target: windows-x64
module test;
macro int create_int2() {
$$unreachable();
return 2;
}
fn void test()
{
int x = create_int2();
}
macro int? create_int()
{
$$unreachable();
return 2;
}
fn void tester(int x)
{
}
fn void tester_test()
{
(void)tester(create_int());
}
fn void tester_test2()
{
(void)tester(create_int2());
}
/* #expect: test.ll
; Function Attrs: nounwind uwtable
define void @test.test() #0 {
entry:
%x = alloca i32, align 4
%blockret = alloca i32, align 4
unreachable
after_macro: ; No predecessors!
store i32 poison, ptr %x, align 4
ret void
}
; Function Attrs: nounwind uwtable
define void @test.tester(i32 %0) #0 {
entry:
ret void
}
; Function Attrs: nounwind uwtable
define void @test.tester_test() #0 {
entry:
%blockret = alloca i32, align 4
unreachable
}
; Function Attrs: nounwind uwtable
define void @test.tester_test2() #0 {
entry:
%blockret = alloca i32, align 4
unreachable
after_macro: ; No predecessors!
call void @test.tester(i32 poison)
ret void
}