Add tests, fixes for tests, reinstate and type-convert stuff marked "bitrot"
[ccom.git] / TEST / tst_lgm-g.c
1 #include <stdio.h>
2
3 /*
4  *      Initilization of structure containing a union:
5  * "tstlgm.c" actually is illegal anyway, since the structure
6  * only has four entries.  This file is more legal.  One set of
7  * compiler fixes allow this to compile (even correctly).
8  */
9
10 struct TEST {
11         int first;
12         int second;
13         union UTEST {
14                 int u_int;
15                 char *u_cptr;
16                 int *u_iptr;
17         } third;
18         int fourth;
19 };
20
21 struct TEST test[] = {
22         {0},
23         {1},
24         {1},
25         {1},
26         {1,2,3,4}, /* was "{1,2,(char *)3,4}," but '82 Ritchie complains */
27         {0},
28         {1,2,0,0},
29         {1,2,0,0},
30         {0,0,0,0},
31         {1}
32 };
33
34 main()
35 {
36         int i;
37
38         printf("Size of TEST structure = %d\n",sizeof(struct TEST));
39         printf("Size of structure test = %d\n",sizeof(test));
40
41         for (i = 0; i < 10; ++i){
42                 printf("Cycle %d ",i);
43                 printf("First = %d\tSecond = %d\t",
44                         test[i].first, test[i].second);
45                 printf("Union third = %d\t", test[i].third.u_int);
46                 printf("Fourth = %d\n", test[i].fourth);
47         }
48 }