Files
c3c/test/test_suite/functions/splat_initializer.c3t
Christoffer Lerno bf26898645 Fixed test.
2025-12-19 19:01:19 +01:00

67 lines
2.6 KiB
Plaintext

// #target: mingw-x64
module test;
import std;
struct ParentType
{
int a;
int b;
int x;
int y;
}
struct ChildType
{
inline ParentType p;
int c;
int ef;
char[10] ff;
}
const ParentType ABC = { .a = 1, .b = 2, .x = 12312, .y = -1 };
const ChildType ABC2 = { .a = 1, .b = 1, .x = 12, .y = 0 };
ChildType gc = { ...ABC2, .b = 7, .c = 8 };
ChildType gc2 = { ...ABC, .b = 7, .c = 8 };
fn void main()
{
ParentType some_p = { .a = 1, .b = 2, .x = 12312, .y = -1 };
ChildType c = { ...some_p, .b = 7, .c = 8 };
ParentType t = { ...some_p, .b = 343};
ChildType d = gc;
ChildType e = gc2;
}
/* #expect: test.ll
@"$ct.test.ParentType" = linkonce global %.introspect { i8 10, i64 0, ptr null, i64 16, i64 0, i64 4, [0 x i64] zeroinitializer }, comdat, align 8
@"$ct.test.ChildType" = linkonce global %.introspect { i8 10, i64 ptrtoint (ptr @"$ct.test.ParentType" to i64), ptr null, i64 36, i64 0, i64 4, [0 x i64] zeroinitializer }, comdat, align 8
@test.ABC = local_unnamed_addr constant %ParentType { i32 1, i32 2, i32 12312, i32 -1 }, align 4
@test.ABC2 = local_unnamed_addr constant %ChildType { %ParentType { i32 1, i32 1, i32 12, i32 0 }, i32 0, i32 0, [10 x i8] zeroinitializer }, align 4
@test.gc = local_unnamed_addr global %ChildType { %ParentType { i32 1, i32 7, i32 12, i32 0 }, i32 8, i32 0, [10 x i8] zeroinitializer }, align 4
@test.gc2 = local_unnamed_addr global %ChildType { %ParentType { i32 1, i32 7, i32 12312, i32 -1 }, i32 8, i32 0, [10 x i8] zeroinitializer }, align 4
@.__const = private unnamed_addr constant %ParentType { i32 1, i32 2, i32 12312, i32 -1 }, align 4
; Function Attrs: nounwind uwtable
define void @test.main() #0 {
entry:
%some_p = alloca %ParentType, align 4
%c = alloca %ChildType, align 4
%t = alloca %ParentType, align 4
%d = alloca %ChildType, align 4
%e = alloca %ChildType, align 4
call void @llvm.memcpy.p0.p0.i32(ptr align 4 %some_p, ptr align 4 @.__const, i32 16, i1 false)
call void @llvm.memset.p0.i64(ptr align 4 %c, i8 0, i64 36, i1 false)
call void @llvm.memcpy.p0.p0.i32(ptr align 4 %c, ptr align 4 %some_p, i32 16, i1 false)
%ptradd = getelementptr inbounds i8, ptr %c, i64 4
store i32 7, ptr %ptradd, align 4
%ptradd1 = getelementptr inbounds i8, ptr %c, i64 16
store i32 8, ptr %ptradd1, align 4
call void @llvm.memcpy.p0.p0.i32(ptr align 4 %t, ptr align 4 %some_p, i32 16, i1 false)
%ptradd2 = getelementptr inbounds i8, ptr %t, i64 4
store i32 343, ptr %ptradd2, align 4
call void @llvm.memcpy.p0.p0.i32(ptr align 4 %d, ptr align 4 @test.gc, i32 36, i1 false)
call void @llvm.memcpy.p0.p0.i32(ptr align 4 %e, ptr align 4 @test.gc2, i32 36, i1 false)
ret void
}