Beautified (indented) compiler source according to gnu coding style
[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   };
43
44
45 struct chars char_struct;
46
47 void
48 done ()
49 {
50
51   dummy++;
52
53 }
54
55 void
56 struct_test (void)
57 {
58
59   if (char_struct.c0 || char_struct.c1)
60     failures++;
61
62   char_struct.c0++;
63
64   if (char_struct.c0 != 1)
65     failures++;
66 }
67
68 void
69 ptr_to_struct (struct chars *p)
70 {
71
72   if (p->c1)
73     failures++;
74
75
76   p->c1++;
77
78   if (p->c1 != 1)
79     failures++;
80 }
81
82
83 void
84 main (void)
85 {
86
87
88   char_struct.c0 = 0;
89   char_struct.c1 = 0;
90   struct_test ();
91   ptr_to_struct (&char_struct);
92
93   success = failures;
94   done ();
95 }