105267
|
1 /* Test file for C language.
|
|
2 * Attempt to include as many aspects of the C language as possible.
|
|
3 */
|
|
4 /* types of include files */
|
|
5 #include "includeme1.h"
|
|
6 #include <includeme2.h>
|
|
7 #include <subdir/includeme3.h>
|
|
8 #include <includeme.notanhfile>
|
|
9 #include <stdlib.h>
|
|
10 #include <cmath>
|
|
11
|
|
12 #if 0
|
|
13 int dont_show_function()
|
|
14 {
|
|
15 }
|
|
16 #endif
|
|
17
|
|
18 /* Global types */
|
|
19 struct mystruct1 {
|
|
20 int slot11;
|
|
21 char slot12;
|
|
22 float slot13;
|
|
23 };
|
|
24
|
|
25 struct mystruct2 {
|
|
26 int slot21;
|
|
27 char slot22;
|
|
28 float slot23;
|
|
29 } var_of_type_mystruct2;
|
|
30
|
|
31 struct {
|
|
32 int slot31;
|
|
33 char slot32;
|
|
34 float slot33;
|
|
35 } var_of_anonymous_struct;
|
|
36
|
|
37 typedef struct mystruct1 typedef_of_mystruct1;
|
|
38 typedef struct mystruct1 *typedef_of_pointer_mystruct1;
|
|
39 typedef struct { int slot_a; } typedef_of_anonymous_struct;
|
|
40 typedef struct A {
|
|
41 } B;
|
|
42
|
|
43 typedef struct mystruct1 td1, td2;
|
|
44
|
|
45 union myunion1 {
|
|
46 int slot41;
|
|
47 char slot42;
|
|
48 float slot43;
|
|
49 };
|
|
50
|
|
51 union myunion2 {
|
|
52 int slot51;
|
|
53 char slot52;
|
|
54 float slot53;
|
|
55 } var_of_type_myunion2;
|
|
56
|
|
57 struct {
|
|
58 int slot61;
|
|
59 char slot72;
|
|
60 float slot83;
|
|
61 } var_of_anonymous_union;
|
|
62
|
|
63 typedef union myunion1 typedef_of_myunion1;
|
|
64 typedef union myunion1 *typedef_of_pointer_myunion1;
|
|
65 typedef union { int slot_a; } typedef_of_anonymous_union;
|
|
66
|
|
67 enum myenum1 { enum11 = 1, enum12 };
|
|
68 enum myenum2 { enum21, enum22 = 2 } var_of_type_myenum2;
|
|
69 enum { enum31, enum32 } var_of_anonymous_enum;
|
|
70
|
|
71 typedef enum myenum1 typedef_of_myenum1;
|
|
72 typedef enum myenum1 *typedef_of_pointer_myenum1;
|
|
73 typedef enum { enum_a = 3, enum_b } typedef_of_anonymous_enum;
|
|
74
|
|
75 typedef int typedef_of_int;
|
|
76
|
|
77 /* Here are some simpler variable types */
|
|
78 int var1;
|
|
79 int varbit1:1;
|
|
80 char var2;
|
|
81 float var3;
|
|
82 mystruct1 var3;
|
|
83 struct mystruct1 var4;
|
|
84 union myunion1 var5;
|
|
85 enum myenum1 var6;
|
|
86
|
|
87 char *varp1;
|
|
88 char **varp2;
|
|
89 char varv1[1];
|
|
90 char varv2[1][2];
|
|
91
|
|
92 char *varpa1 = "moose";
|
|
93 struct mystruct2 vara2 = { 1, 'a', 0.0 };
|
|
94 enum myenum1 vara3 = enum11;
|
|
95 int vara4 = (int)0.0;
|
|
96 int vara5 = funcall();
|
|
97
|
|
98 int mvar1, mvar2, mvar3;
|
|
99 char *mvarp1, *mvarp2, *mvarp3;
|
|
100 char *mvarpa1 = 'a', *mvarpa2 = 'b', *mvarpa3 = 'c';
|
|
101 char mvaras1[10], mvaras2[12][13], *mvaras3 = 'd';
|
|
102
|
|
103 static register const unsigned int tmvar1;
|
|
104
|
|
105 #define MACRO1 1
|
|
106 #define MACRO2(foo) (1+foo)
|
|
107
|
|
108 /* Here are some function prototypes */
|
|
109
|
|
110 /* This is legal, but I decided not to support inferred integer
|
|
111 * types on functions and variables.
|
|
112 */
|
|
113 fun0();
|
|
114 int funp1();
|
|
115 char funp2(int arg11);
|
|
116 float funp3(char arg21, char arg22);
|
|
117 struct mystrct1 funp4(struct mystruct2 arg31, union myunion2 arg32);
|
|
118 enum myenum1 funp5(char *arg41, union myunion1 *arg42);
|
|
119
|
|
120 char funpp1 __P(char argp1, struct mystruct2 argp2, char *arg4p);
|
|
121
|
|
122 int fun1();
|
|
123
|
|
124 /* Here is a function pointer */
|
|
125 int (*funcptr)(int a, int b);
|
|
126
|
|
127 /* Function Definitions */
|
|
128
|
|
129 /* This is legal, but I decided not to support inferred integer
|
|
130 * types on functions and variables.
|
|
131 */
|
|
132 fun0()
|
|
133 {
|
|
134 int sv = 0;
|
|
135 }
|
|
136
|
|
137 int fun1 ()
|
|
138 {
|
|
139 int sv = 1;
|
|
140 }
|
|
141
|
|
142 int fun1p1 (void)
|
|
143 {
|
|
144 int sv = 1;
|
|
145 }
|
|
146
|
|
147 char fun2(int arg_11)
|
|
148 {
|
|
149 char sv = 2;
|
|
150 }
|
|
151
|
|
152 float fun3(char arg_21, char arg_22)
|
|
153 {
|
|
154 char sv = 3;
|
|
155 }
|
|
156
|
|
157 struct mystrct1 fun4(struct mystruct2 arg31, union myunion2 arg32)
|
|
158 {
|
|
159 sv = 4;
|
|
160 }
|
|
161
|
|
162 enum myenum1 fun5(char *arg41, union myunion1 *arg42)
|
|
163 {
|
|
164 sv = 5;
|
|
165 }
|
|
166
|
|
167 /* Functions with K&R syntax. */
|
|
168 struct mystrct1 funk1(arg_31, arg_32)
|
|
169 struct mystruct2 arg_31;
|
|
170 union myunion2 arg32;
|
|
171 {
|
|
172 sv = 4;
|
|
173 }
|
|
174
|
|
175 enum myenum1 *funk2(arg_41, arg_42)
|
|
176 char *arg_41;
|
|
177 union myunion1 *arg_42;
|
|
178 {
|
|
179 sv = 5;
|
|
180
|
|
181 if(foo) {
|
|
182 }
|
|
183 }
|
|
184
|
|
185 int funk3(arg_51, arg_53)
|
|
186 int arg_51;
|
|
187 char arg_53;
|
|
188 {
|
|
189 char q = 'a';
|
|
190 int sv = 6;
|
|
191 td1 ms1;
|
|
192 enum myenum1 testconst;
|
|
193
|
|
194 /* Function argument analysis */
|
|
195 funk3(ms1.slot11, arg_53 );
|
|
196 sv = 7;
|
|
197
|
|
198 /* Slot deref on assignee */
|
|
199 ms1.slot11 = s;
|
|
200
|
|
201 /* Enum/const completion */
|
|
202 testconst = e;
|
|
203
|
|
204 /* Bad var/slot and param */
|
|
205 blah.notafunction(moose);
|
|
206
|
|
207 /* Print something. */
|
|
208 printf("Moose", );
|
|
209
|
|
210 tan();
|
|
211 }
|
|
212
|
|
213 int funk4_fixme(arg_61, arg_62)
|
|
214 int arg_61, arg_62;
|
|
215 {
|
|
216
|
|
217 }
|
|
218
|
|
219 /* End of C tests */
|
105377
|
220
|
|
221 /* arch-tag: ac9c7740-05ad-4821-a0b4-5db4357750ae
|
|
222 (do not change this comment) */
|