4
* Copyright (c) 2006 KOGURO, Naoki (naoki@koguro.net)
6
* Permission is hereby granted, free of charge, to any person
7
* obtaining a copy of this software and associated
8
* documentation files (the "Software"), to deal in the
9
* Software without restriction, including without limitation
10
* the rights to use, copy, modify, merge, publish, distribute,
11
* sublicense, and/or sell copies of the Software, and to
12
* permit persons to whom the Software is furnished to do so,
13
* subject to the following conditions:
15
* The above copyright notice and this permission notice shall
16
* be included in all copies or substantial portions of the
19
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
20
* KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
21
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
23
* OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
25
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37
extern short var_short;
40
extern long long var_longlong;
41
extern unsigned char var_uchar;
42
extern unsigned short var_ushort;
43
extern unsigned int var_uint;
44
extern unsigned long var_ulong;
45
extern unsigned long long var_ulonglong;
46
extern float var_float;
47
extern double var_double;
48
extern char *var_string;
50
extern void test_var(void);
72
struct test_ulonglong {
74
unsigned long long value;
97
struct test_slonglong {
99
signed long long value;
117
#define DEFINE_TEST_STRUCT_ARRAY(type, ctype) \
118
struct test_array_##type { \
123
DEFINE_TEST_STRUCT_ARRAY(uchar, unsigned char)
124
DEFINE_TEST_STRUCT_ARRAY(ushort, unsigned short)
125
DEFINE_TEST_STRUCT_ARRAY(uint, unsigned int)
126
DEFINE_TEST_STRUCT_ARRAY(ulong, unsigned long)
127
DEFINE_TEST_STRUCT_ARRAY(ulonglong, unsigned long long)
128
DEFINE_TEST_STRUCT_ARRAY(schar, signed char)
129
DEFINE_TEST_STRUCT_ARRAY(sshort, signed short)
130
DEFINE_TEST_STRUCT_ARRAY(sint, signed int)
131
DEFINE_TEST_STRUCT_ARRAY(slong, signed long)
132
DEFINE_TEST_STRUCT_ARRAY(slonglong, signed long long)
133
DEFINE_TEST_STRUCT_ARRAY(float, float)
134
DEFINE_TEST_STRUCT_ARRAY(double, double)
135
DEFINE_TEST_STRUCT_ARRAY(string, char*)
137
extern struct test_uchar add_struct_uchar(struct test_uchar v1,
138
struct test_uchar v2);
139
extern struct test_ushort add_struct_ushort(struct test_ushort v1,
140
struct test_ushort v2);
141
extern struct test_uint add_struct_uint(struct test_uint v1,
142
struct test_uint v2);
143
extern struct test_ulong add_struct_ulong(struct test_ulong v1,
144
struct test_ulong v2);
145
extern struct test_ulonglong add_struct_ulonglong(struct test_ulonglong v1,
146
struct test_ulonglong v2);
147
extern struct test_schar add_struct_schar(struct test_schar v1,
148
struct test_schar v2);
149
extern struct test_sshort add_struct_sshort(struct test_sshort v1,
150
struct test_sshort v2);
151
extern struct test_sint add_struct_sint(struct test_sint v1,
152
struct test_sint v2);
153
extern struct test_slong add_struct_slong(struct test_slong v1,
154
struct test_slong v2);
155
extern struct test_slonglong add_struct_slonglong(struct test_slonglong v1,
156
struct test_slonglong v2);
157
extern struct test_float add_struct_float(struct test_float v1,
158
struct test_float v2);
159
extern struct test_double add_struct_double(struct test_double v1,
160
struct test_double v2);
161
extern struct test_string add_struct_string(struct test_string v1,
162
struct test_string v2);
164
#define EXTERN_FUNC_TEST_STRUCT_ARRAY(type) \
165
extern struct test_array_##type \
166
add_struct_array_##type(struct test_array_##type v1, \
167
struct test_array_##type v2);
169
EXTERN_FUNC_TEST_STRUCT_ARRAY(uchar)
170
EXTERN_FUNC_TEST_STRUCT_ARRAY(ushort)
171
EXTERN_FUNC_TEST_STRUCT_ARRAY(uint)
172
EXTERN_FUNC_TEST_STRUCT_ARRAY(ulong)
173
EXTERN_FUNC_TEST_STRUCT_ARRAY(ulonglong)
174
EXTERN_FUNC_TEST_STRUCT_ARRAY(schar)
175
EXTERN_FUNC_TEST_STRUCT_ARRAY(sshort)
176
EXTERN_FUNC_TEST_STRUCT_ARRAY(sint)
177
EXTERN_FUNC_TEST_STRUCT_ARRAY(slong)
178
EXTERN_FUNC_TEST_STRUCT_ARRAY(slonglong)
179
EXTERN_FUNC_TEST_STRUCT_ARRAY(float)
180
EXTERN_FUNC_TEST_STRUCT_ARRAY(double)
181
EXTERN_FUNC_TEST_STRUCT_ARRAY(string)
183
extern unsigned char add_uchar(unsigned char v1, unsigned char v2);
184
extern signed char add_schar(signed char v1, signed char v2);
185
extern unsigned short add_ushort(unsigned short v1, unsigned short v2);
186
extern signed short add_sshort(signed short v1, signed short v2);
187
extern unsigned int add_uint(unsigned int v1, unsigned int v2);
188
extern signed int add_sint(signed int v1, signed int v2);
189
extern unsigned long add_ulong(unsigned long v1, unsigned long v2);
190
extern signed long add_slong(signed long v1, signed long v2);
191
extern unsigned long long add_ulonglong(unsigned long long v1,
192
unsigned long long v2);
193
extern signed long long add_slonglong(signed long long v1, signed long long v2);
194
extern float add_float(float v1, float v2);
195
extern double add_double(double v1, double v2);
196
extern const char *add_string(const char *v1, const char *v2);
198
extern unsigned char *add_array_uchar(int size, unsigned char v1[],
200
extern signed char *add_array_schar(int size, signed char v1[],
202
extern unsigned short *add_array_ushort(int size, unsigned short v1[],
203
unsigned short v2[]);
204
extern signed short *add_array_sshort(int size, signed short v1[],
206
extern unsigned int *add_array_uint(int size, unsigned int v1[],
208
extern signed int *add_array_sint(int size, signed int v1[], signed int v2[]);
209
extern unsigned long *add_array_ulong(int size, unsigned long v1[],
211
extern signed long *add_array_slong(int size, signed long v1[],
213
extern unsigned long long *add_array_ulonglong(int size, unsigned long long v1[],
214
unsigned long long v2[]);
215
extern signed long long *add_array_slonglong(int size, signed long long v1[],
216
signed long long v2[]);
217
extern float *add_array_float(int size, float v1[], float v2[]);
218
extern double *add_array_double(int size, double v1[], double v2[]);
219
extern char **add_array_string(int size, const char *v1[], const char *v2[]);
221
extern unsigned char callback_uchar(unsigned char (*fn)(unsigned char,
223
unsigned char v1, unsigned char v2);
224
extern signed char callback_schar(signed char (*)(signed char, signed char),
225
signed char v1, signed char v2);
226
extern unsigned short callback_ushort(unsigned short (*fn)(unsigned short,
228
unsigned short v1, unsigned short v2);
229
extern signed short callback_sshort(signed short (*fn)(signed short,
231
signed short v1, signed short v2);
232
extern unsigned int callback_uint(unsigned int (*fn)(unsigned int, unsigned int),
233
unsigned int v1, unsigned int v2);
234
extern signed int callback_sint(signed int (*fn)(signed int, signed int),
235
signed int v1, signed int v2);
236
extern unsigned long callback_ulong(unsigned long (*fn)(unsigned long,
238
unsigned long v1, unsigned long v2);
239
extern signed long callback_slong(signed long (*fn)(signed long, signed long),
240
signed long v1, signed long v2);
241
extern unsigned long long callback_ulonglong(unsigned long long (*fn)(unsigned long long,
243
unsigned long long v1, unsigned long long v2);
244
extern signed long long callback_slonglong(signed long long (*fn)(signed long long,
246
signed long long v1, signed long long v2);
247
extern float callback_float(float (*fn)(float, float), float v1, float v2);
248
extern double callback_double(double (*fn)(double, double), double v1, double v2);
249
extern const char *callback_string(const char *(*fn)(const char *, const char*),
250
const char *v1, const char *v2);
252
#define EXTERN_FUNC_VAARG(type, ctype) extern ctype *vaarg_##type(int nargs, ...);
253
EXTERN_FUNC_VAARG(uint, unsigned int)
254
EXTERN_FUNC_VAARG(ulong, unsigned long)
255
EXTERN_FUNC_VAARG(ulonglong, unsigned long long)
256
EXTERN_FUNC_VAARG(sint, signed int)
257
EXTERN_FUNC_VAARG(slong, signed long)
258
EXTERN_FUNC_VAARG(slonglong, signed long long)
259
EXTERN_FUNC_VAARG(double, double)
260
EXTERN_FUNC_VAARG(string, char*)
272
#define EXTERN_FUNC_TEST_UNION(name) extern union test test_union_##name(union test v1, union test v2);
273
EXTERN_FUNC_TEST_UNION(c)
274
EXTERN_FUNC_TEST_UNION(s)
275
EXTERN_FUNC_TEST_UNION(i)
276
EXTERN_FUNC_TEST_UNION(l)
277
EXTERN_FUNC_TEST_UNION(ll)
278
EXTERN_FUNC_TEST_UNION(f)
279
EXTERN_FUNC_TEST_UNION(d)
280
EXTERN_FUNC_TEST_UNION(str)
282
extern void test_modify(int *v);
284
extern int incomplete_array[];
286
extern int test_null_ptr(void *ptr1);
287
extern int test_null_func_ptr(int (*fn)(void *ptr));
291
extern int *test_ptr;
292
extern int test_array[];
293
extern void init_test_ptr();
295
#define post_pp(x) ((x)++)
296
#define post_mm(x) ((x)--)
297
#define pre_pp(x) (++(x))
298
#define pre_mm(x) (--(x))
299
#define plus(x, y) ((x)+(y))
300
#define minus(x, y) ((x)-(y))
302
struct bitfield_rec {
312
extern struct bitfield_rec test_bitfield(struct bitfield_rec dat);
314
#define IFMAC(test,then_expr,else_expr) ((test)?(then_expr):(else_expr))
316
/* test funcations for inline function */
317
inline int return_const()
322
inline char *return_string()
327
inline int ref_array(int a[])
332
inline void funccall1()
337
inline int funcall2(int a, int b)
339
return add_sint(a, b);
342
inline int ref_struct1()
349
inline int ref_struct2(struct test_sint *p)
354
inline int post_inc()
361
inline int post_dec()
380
inline int unary_plus()
385
inline int unary_minus()
390
inline int unary_logneg(int a)
395
inline int unary_bitneg(int a)
400
inline int unary_ref()
403
sscanf("123", "%d", &a);
407
inline int *unary_deref()
409
void *p0 = (int*) malloc(sizeof(int));
415
inline long op_sizeof()
420
inline int mul(int a, int b)
425
inline int divi(int a, int b)
430
inline int mod(int a, int b)
435
inline int add(int a, int b)
440
inline int sub(int a, int b)
445
inline int left_shift(int a, int b)
450
inline int right_shift(int a, int b)
455
inline int op_lt(int a, int b)
463
inline int op_gt(int a, int b)
472
inline int op_lteq(int a, int b)
480
inline int op_gteq(int a, int b)
489
inline int op_eq(int a, int b)
498
inline int op_noteq(int a, int b)
507
inline int bitand(int a, int b)
512
inline int bitxor(int a, int b)
517
inline int bitor(int a, int b)
522
inline int op_logand(int a, int b, int c)
524
if ((a == b) && (b == c)) {
531
inline int op_logor(int a, int b, int c)
533
return ((a == b) || (b == c))?1:0;
536
inline int assign_mul(int a, int b)
542
inline int assign_div(int a, int b)
548
inline int assign_mod(int a, int b)
554
inline int assign_add(int a, int b)
560
inline int assign_sub(int a, int b)
566
inline int assign_left_shift(int a, int b)
572
inline int assign_right_shift(int a, int b)
578
inline int assign_bitand(int a, int b)
584
inline int assign_bitor(int a, int b)
590
inline int assign_bitxor(int a, int b)
596
inline int multi_expr(int a, int b)
598
return (a + b), (a - b), (a * b);
601
inline int test_while()
612
inline int test_while_break()
624
inline int test_while_continue()
637
inline int test_dowhile()
647
inline int test_dowhile_break()
658
inline int test_dowhile_continue()
667
} while ((0 < i) && (i < 10));
671
inline int test_for()
675
for (i = 0, sum = 0; i <= 10; ++i) {
681
inline int test_for_noinit_notest_noupdate()
691
inline int test_for_noinit_notest()
700
inline int test_for_noinit_noupdate()
709
inline int test_for_noinit()
712
for (;i < 10; sum += ++i);
716
inline int test_for_notest_noupdate()
719
for (i = 0, sum = 0;;) {
726
inline int test_for_notest()
729
for (i = 0, sum = 0;;sum += ++i) {
735
inline int test_for_noupdate()
738
for (i = sum = 0;i < 10;) {
744
inline int offset_calc()
746
return (int) &(((struct test_uchar*)0)->value);
749
inline void not_supported(int a)
760
ISO/IEC 9899:1999 6.7.5.3
761
a declaration of a parameter as ``function returning type'' shall be
762
adjusted to ``pointer to function returning type''
764
extern char *param_func_test(void *allocator(size_t));
766
typedef signed int (*sint_adder)(signed int v1, signed int v2);
767
extern sint_adder get_fptr();