Imported Upstream version 2.9.0
[debian/cc1111] / src / regression / struct1.c
1 #include "gpsim_assert.h"
2 // Addition tests
3
4 /* bit types are not ANSI - so provide a way of disabling bit types
5  * if this file is used to test other compilers besides SDCC */
6 #define SUPPORT_BIT_TYPES 0
7
8 /* Some compilers that support bit types do not support bit arithmetic 
9  * (like bitx = bity + bitz;) */
10 #define SUPPORT_BIT_ARITHMETIC 1
11
12 unsigned char failures = 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
44 struct chars struct1;
45
46 void
47 done()
48 {
49   ASSERT(MANGLE(failures) == 0);
50   PASSED();
51 }
52
53 void
54 struct_test (void)
55 {
56
57   if (struct1.c0 || struct1.c1)
58     failures++;
59
60   struct1.c0++;
61
62   if (struct1.c0 != 1)
63     failures++;
64 }
65 /*
66 void
67 ptr_to_struct (struct chars *p)
68 {
69
70   if (p->c1)
71     failures++;
72
73
74   p->c1++;
75
76   if (p->c1 != 1)
77     failures++;
78 }
79 */
80 void add_chars(void)
81 {
82
83   achar0 = struct1.c0 + struct1.c1;
84
85   if(achar0 != 1)
86     failures++;
87 }
88
89 void
90 main (void)
91 {
92
93
94   struct1.c0 = 0;
95   struct1.c1 = 0;
96   struct_test ();
97   //  ptr_to_struct (&struct1);
98
99   struct1.c0 = 0;
100   struct1.c1 = 1;
101   add_chars();
102
103   done ();
104 }