Steve Tell fixed a nested for-loop bug in the PIC Port
[fw/sdcc] / src / regression / struct1.c
1 #define __16F873
2 #include "p16f873.h"
3 //#include "p16c84.h"
4 // Addition tests
5
6 /* bit types are not ANSI - so provide a way of disabling bit types
7  * if this file is used to test other compilers besides SDCC */
8 #define SUPPORT_BIT_TYPES 1
9
10 /* Some compilers that support bit types do not support bit arithmetic 
11  * (like bitx = bity + bitz;) */
12 #define SUPPORT_BIT_ARITHMETIC 1
13
14 unsigned char success = 0;
15 unsigned char failures = 0;
16 unsigned char dummy = 0;
17
18 #if SUPPORT_BIT_TYPES
19
20 bit bit0 = 0;
21 bit bit1 = 0;
22 bit bit2 = 0;
23 bit bit3 = 0;
24 bit bit4 = 0;
25 bit bit5 = 0;
26 bit bit6 = 0;
27 bit bit7 = 0;
28 bit bit8 = 0;
29 bit bit9 = 0;
30 bit bit10 = 0;
31 bit bit11 = 0;
32
33 #endif
34
35 unsigned int aint0 = 0;
36 unsigned int aint1 = 0;
37 unsigned char achar0 = 0;
38 unsigned char achar1 = 0;
39 unsigned char *acharP = 0;
40
41 struct chars
42   {
43     unsigned char c0, c1;
44     unsigned int  i0, i1;
45   };
46
47
48 struct chars struct1;
49
50 void
51 done ()
52 {
53
54   dummy++;
55
56 }
57
58 void
59 struct_test (void)
60 {
61
62   if (struct1.c0 || struct1.c1)
63     failures++;
64
65   struct1.c0++;
66
67   if (struct1.c0 != 1)
68     failures++;
69 }
70 /*
71 void
72 ptr_to_struct (struct chars *p)
73 {
74
75   if (p->c1)
76     failures++;
77
78
79   p->c1++;
80
81   if (p->c1 != 1)
82     failures++;
83 }
84 */
85 void add_chars(void)
86 {
87
88   achar0 = struct1.c0 + struct1.c1;
89
90   if(achar0 != 1)
91     failures++;
92 }
93
94 void
95 main (void)
96 {
97
98
99   struct1.c0 = 0;
100   struct1.c1 = 0;
101   struct_test ();
102   //  ptr_to_struct (&struct1);
103
104   struct1.c0 = 0;
105   struct1.c1 = 1;
106   add_chars();
107
108   success = failures;
109   done ();
110 }