Added more regression test to the pic port. Added support for <<, >>, ^
[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   {
41     unsigned char c0, c1;
42     unsigned int  i0, i1;
43   };
44
45
46 struct chars struct1;
47
48 void
49 done ()
50 {
51
52   dummy++;
53
54 }
55
56 void
57 struct_test (void)
58 {
59
60   if (struct1.c0 || struct1.c1)
61     failures++;
62
63   struct1.c0++;
64
65   if (struct1.c0 != 1)
66     failures++;
67 }
68 /*
69 void
70 ptr_to_struct (struct chars *p)
71 {
72
73   if (p->c1)
74     failures++;
75
76
77   p->c1++;
78
79   if (p->c1 != 1)
80     failures++;
81 }
82 */
83 void add_chars(void)
84 {
85
86   achar0 = struct1.c0 + struct1.c1;
87
88   if(achar0 != 1)
89     failures++;
90 }
91
92 void
93 main (void)
94 {
95
96
97   struct1.c0 = 0;
98   struct1.c1 = 0;
99   struct_test ();
100   //  ptr_to_struct (&struct1);
101
102   struct1.c0 = 0;
103   struct1.c1 = 1;
104   add_chars();
105
106   success = failures;
107   done ();
108 }