Files
c3c/test/test_suite/struct/member_access.c3
Christoffer Lerno 4da36dfed9 Optimized and improved aggregate initialization. Compound literal updated to Foo({ 1, 2 })-style. ".name = x" style initialization for named arguments and designated initializers. Added runtime messages on panics. subarrays convert implictly to pointers. len/len() functions. Fix taking slice of pointer. Vararg fixes
Consistent length typedef.

First stab at initializers.

Change compound literal to Foo({ 1, 2 }) style.

Fixed up some tests.

Optimize the zero struct codegen.

Optimize union empty initializer.

Fix issues with unions. Added alignment to globals. Added some union tests.

Use puts to emit error messages during runtime. Fixup of int[] -> int* style conversions.

Fix implicit conversion of int[3]* -> int*

Fix int[] size. Use () to invoke the length of a subarray. Fix taking a slice of a pointer. Limit the number of members in a struct.

Fixes to vararg using debug and cleanups to slices.
2020-12-22 21:55:52 +01:00

88 lines
999 B
Plaintext

module test;
struct Multi
{
int a, b, c;
}
struct Point
{
int a;
struct bb
{
int b;
}
struct
{
int b;
int c;
struct
{
Point* p;
}
}
union
{
int d;
short e;
}
union uu {
int d;
ushort e;
}
}
func void tester()
{
Multi m;
m.a = 1;
Point p;
p.a = 1;
p.bb.b = 2;
p.b = 3;
p.c = 4;
p.p = null;
p.d = 5;
p.e = 6;
p.uu.d = 7;
p.uu.e = 8;
Point *p2 = &p;
p2.bb.b = 3;
p = { .a = 1, .bb.b = 3, .e = 2 };
Point* pp = &p;
pp.a = 20;
}
struct Aa1
{
struct bb
{
int b;
}
struct
{
int c;
}
}
func void test_conversion_struct()
{
Aa1 a1;
int aa = a1.bb; // #error: Cannot implicitly cast 'bb' to 'int'
}
struct Struct
{
int a;
}
func void myfunc()
{
Struct s;
s.b = 10; // #error: There is no field or method 'Struct.b'
}