mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
46 lines
874 B
Plaintext
46 lines
874 B
Plaintext
// #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
|
|
}
|