mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Additional #2210 fixes.
This commit is contained in:
45
test/test_suite/assert/unreachable_macro_3.c3t
Normal file
45
test/test_suite/assert/unreachable_macro_3.c3t
Normal 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
|
||||
}
|
||||
24
test/test_suite/assert/unreachable_macro_4.c3t
Normal file
24
test/test_suite/assert/unreachable_macro_4.c3t
Normal 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
|
||||
}
|
||||
69
test/test_suite/assert/unreachable_macro_fn.c3t
Normal file
69
test/test_suite/assert/unreachable_macro_fn.c3t
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user