From 6436f4c576b65dd8220db7dcd0e7a21f33ac4933 Mon Sep 17 00:00:00 2001 From: lemon Date: Wed, 8 Oct 2025 23:03:06 +0200 Subject: initial implementation of run-time array/aggregate initializers --- test/test.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/test.c b/test/test.c index c44d1a0..1a50690 100644 --- a/test/test.c +++ b/test/test.c @@ -40,8 +40,7 @@ struct quad { }; struct quad quad(long x, long y, long z, long w) { - struct quad q; - q.x = x, q.y = y, q.z = z, q.w = w; + struct quad q = {x,y,z,w}; return q; } @@ -62,9 +61,11 @@ int test2(struct big *b) { struct f2 { float f,g; }; struct f2 f2test(struct f2 *r) { + struct f2 q = {1,3,.f=2}; + *r = q; return *r; } -#if 0 +#if 1 void fill(char *p, int c, unsigned long n) { int t; @@ -82,7 +83,7 @@ enum ball { X = 2147483647, Y, Z, - W = ~0ull + W = ~0ull //warn }; enum ball x; @@ -96,4 +97,13 @@ struct f{ char flex[]; }; #endif + +int main() { + char str[] = "abcdef!"; + int arr[] = {[4]=1,9001}; + str[1]&=~0x20; + extern int printf(char *, ...); + printf("%s %d,%d\n",str, arr[0],arr[5]); + return sizeof arr; +} // -- cgit v1.2.3