PIC port on going development.most of addition, arrays, pointers,
[fw/sdcc] / src / regression / struct1.c
1 //#include "p16c84.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 1
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 success=0;
13 unsigned char failures=0;
14 unsigned char dummy=0;
15
16 #if SUPPORT_BIT_TYPES
17
18 bit bit0 = 0;
19 bit bit1 = 0;
20 bit bit2 = 0;
21 bit bit3 = 0;
22 bit bit4 = 0;
23 bit bit5 = 0;
24 bit bit6 = 0;
25 bit bit7 = 0;
26 bit bit8 = 0;
27 bit bit9 = 0;
28 bit bit10 = 0;
29 bit bit11 = 0;
30
31 #endif
32
33 unsigned int aint0 = 0;
34 unsigned int aint1 = 0;
35 unsigned char achar0 = 0;
36 unsigned char achar1 = 0;
37 unsigned char *acharP = 0;
38
39 struct chars {
40   unsigned char c0,c1;
41 };
42
43
44 struct chars char_struct;
45
46 void done()
47 {
48
49   dummy++;
50
51 }
52
53 void struct_test(void)
54 {
55
56   if(char_struct.c0 || char_struct.c1)
57     failures++;
58
59   char_struct.c0++;
60
61   if(char_struct.c0 != 1)
62     failures++;
63 }
64
65 void ptr_to_struct(struct chars *p)
66 {
67
68   if(p->c1)
69     failures++;
70
71
72   p->c1++;
73
74   if(p->c1 != 1)
75     failures++;
76 }
77
78
79 void main(void)
80 {
81
82
83   char_struct.c0 = 0;
84   char_struct.c1 = 0;
85   struct_test();
86   ptr_to_struct(&char_struct);
87
88   success = failures;
89   done();
90 }