Files
c3c/test/test_suite/union/union_in_struct.c3t
2023-04-28 19:11:57 +02:00

46 lines
1.8 KiB
C

// #target: macos-x64
module test;
struct Foo
{
char c;
union {
int a;
double b;
}
int z;
}
Foo foo1 = { .a = 3, .z = 4 };
Foo foo2 = { .b = 3, .z = 4 };
struct Blend_Map_Entry
{
union vals {
float[5] colour;
double[2] point_Slope;
}
}
Blend_Map_Entry a = { .vals = { .colour = { 1, 2, 3, 4, 5 } } };
Blend_Map_Entry b = { .vals = { .point_Slope = { 6, 7 } } };
Blend_Map_Entry c = { .vals.colour[2] = 1 };
Blend_Map_Entry d = { .vals.colour = { 1, 2, 3, 4, 5 } };
fn void test(Blend_Map_Entry* foo)
{
}
/* #expect: test.ll
%Blend_Map_Entry = type { %vals }
%vals = type { [2 x double], [8 x i8] }
@test.foo1 = local_unnamed_addr global { i8, [4 x i8], { i32, [4 x i8] }, i32 } { i8 0, [4 x i8] undef, { i32, [4 x i8] } { i32 3, [4 x i8] undef }, i32 4 }, align 8
@test.foo2 = local_unnamed_addr global %Foo { i8 0, %.anon { double 3.000000e+00 }, i32 4 }, align 8
@test.a = local_unnamed_addr global { { [5 x float], [4 x i8] } } { { [5 x float], [4 x i8] } { [5 x float] [float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00, float 5.000000e+00], [4 x i8] undef } }, align 8
@test.b = local_unnamed_addr global %Blend_Map_Entry { %vals { [2 x double] [double 6.000000e+00, double 7.000000e+00], [8 x i8] undef } }, align 8
@test.c = local_unnamed_addr global { { { [2 x float], float, [2 x float] }, [4 x i8] } } { { { [2 x float], float, [2 x float] }, [4 x i8] } { { [2 x float], float, [2 x float] } { [2 x float] zeroinitializer, float 1.000000e+00, [2 x float] zeroinitializer }, [4 x i8] undef } }, align 8
@test.d = local_unnamed_addr global { { [5 x float], [4 x i8] } } { { [5 x float], [4 x i8] } { [5 x float] [float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00, float 5.000000e+00], [4 x i8] undef } }, align 8