]> git.sur5r.net Git - cc65/blob - test/val/struct1.c
goto.c warning fix for implicit truncation
[cc65] / test / val / struct1.c
1 /*
2   !!DESCRIPTION!!
3   !!ORIGIN!!      SDCC regression tests
4   !!LICENCE!!     GPL, read COPYING.GPL
5 */
6
7 #include <stdio.h>
8 #include <limits.h>
9
10 unsigned char success = 0;
11 unsigned char failures = 0;
12 unsigned char dummy = 0;
13
14 #if SUPPORT_BIT_TYPES
15
16 bit bit0 = 0;
17 bit bit1 = 0;
18 bit bit2 = 0;
19 bit bit3 = 0;
20 bit bit4 = 0;
21 bit bit5 = 0;
22 bit bit6 = 0;
23 bit bit7 = 0;
24 bit bit8 = 0;
25 bit bit9 = 0;
26 bit bit10 = 0;
27 bit bit11 = 0;
28
29 #endif
30
31 unsigned int aint0 = 0;
32 unsigned int aint1 = 0;
33 unsigned char achar0 = 0;
34 unsigned char achar1 = 0;
35 unsigned char *acharP = 0;
36
37 struct chars
38   {
39     unsigned char c0, c1;
40     unsigned int  i0, i1;
41   };
42
43 struct chars struct1;
44
45 void
46 done ()
47 {
48   dummy++;
49 }
50
51 void
52 struct_test (void)
53 {
54   if (struct1.c0 || struct1.c1)
55     failures++;
56
57   struct1.c0++;
58
59   if (struct1.c0 != 1)
60     failures++;
61 }
62
63 void
64 ptr_to_struct (struct chars *p)
65 {
66   if (p->c1)
67     failures++;
68
69   p->c1++;
70
71   if (p->c1 != 1)
72     failures++;
73 }
74
75 void add_chars(void)
76 {
77   achar0 = struct1.c0 + struct1.c1;
78
79   if(achar0 != 1)
80     failures++;
81 }
82
83 int
84 main (void)
85 {
86   struct1.c0 = 0;
87   struct1.c1 = 0;
88   struct_test ();
89   ptr_to_struct (&struct1);
90
91   struct1.c0 = 0;
92   struct1.c1 = 1;
93   add_chars();
94
95   success = failures;
96   done ();
97   printf("failures: %d\n",failures);
98
99   return failures;
100 }