mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Moved examples around. Updated (and corrected) const initialization. Removed "in" keyword. Added "member" attribute domain. Many fixes in struct padding and alignment and tests. Fixed extern global.
This commit is contained in:
committed by
Christoffer Lerno
parent
564c93700e
commit
3a24fbfa6d
30
test/test_suite/union/empty_unions.c3
Normal file
30
test/test_suite/union/empty_unions.c3
Normal file
@@ -0,0 +1,30 @@
|
||||
module test;
|
||||
|
||||
struct Empty {}
|
||||
union Foo {}
|
||||
union Qu
|
||||
{
|
||||
Qu *x;
|
||||
}
|
||||
|
||||
union Xe
|
||||
{
|
||||
char c;
|
||||
int a, z;
|
||||
long b;
|
||||
void *b1;
|
||||
struct qu
|
||||
{
|
||||
int a;
|
||||
long z;
|
||||
}
|
||||
}
|
||||
|
||||
func Xe foo(Xe a)
|
||||
{
|
||||
a.c = 123;
|
||||
a.a = 39249;
|
||||
a.b = 12301230123123;
|
||||
a.z = 1;
|
||||
return a;
|
||||
}
|
||||
29
test/test_suite/union/union_in_struct.c3t
Normal file
29
test/test_suite/union/union_in_struct.c3t
Normal file
@@ -0,0 +1,29 @@
|
||||
module test;
|
||||
|
||||
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 } };
|
||||
|
||||
func void test(Blend_Map_Entry* foo)
|
||||
{
|
||||
}
|
||||
|
||||
// #expect: union_in_struct.ll
|
||||
|
||||
|
||||
%test.Blend_Map_Entry = type { %test.vals }
|
||||
%test.vals = type { [2 x double], [8 x i8] }
|
||||
|
||||
@a = protected 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
|
||||
@b = protected global %test.Blend_Map_Entry { %test.vals { [2 x double] [double 6.000000e+00, double 7.000000e+00], [8 x i8] undef } }, align 8
|
||||
@c = protected 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
|
||||
@d = protected 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
|
||||
13
test/test_suite/union/union_member_voidcast.c3
Normal file
13
test/test_suite/union/union_member_voidcast.c3
Normal file
@@ -0,0 +1,13 @@
|
||||
module test;
|
||||
|
||||
union Xu
|
||||
{
|
||||
void *b;
|
||||
}
|
||||
|
||||
func Xu foo()
|
||||
{
|
||||
Xu a;
|
||||
a.b = cast(123 as void*);
|
||||
return a;
|
||||
}
|
||||
Reference in New Issue
Block a user