Add ast2 union support

This commit is contained in:
Ganesh Viswanathan 2020-03-16 23:15:34 -05:00
commit 1a9911fc25
3 changed files with 76 additions and 13 deletions

View file

@ -35,8 +35,8 @@ typedef struct A20 { char a1; } A20, A21, *A21p;
typedef struct A22 { int **f1; int *f2[123+132]; } A22;
//Unions
//union UNION1 {int f1; };
//typedef union UNION2 { int **f1; int abc[123+132]; } UNION2;
union U1 {int f1; float f2; };
typedef union U2 { int **f1; int abc[123+132]; } U2;
// Anonymous
//typedef struct { char a1; };

View file

@ -71,4 +71,10 @@ assert A21 is A20
assert A21p is ptr A20
assert A22 is object
testFields(A22, {"f1": "ptr ptr cint", "f2": "array[0..254, ptr cint]"}.toTable())
testFields(A22, {"f1": "ptr ptr cint", "f2": "array[0..254, ptr cint]"}.toTable())
assert U1 is object
assert sizeof(U1) == sizeof(cfloat)
assert U2 is object
assert sizeof(U2) == 256 * sizeof(cint)