struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / z88dk_callee.c
blob64e44d039718ae9b7965c7778a554c4cf0f730ef
1 /** z88dk.c
2 */
3 #include <testfwk.h>
4 #include <stdlib.h>
6 unsigned char f1(unsigned char c) __z88dk_callee
8 return c + 1;
11 unsigned int f2(unsigned int c) __z88dk_callee
13 return c + 1;
16 unsigned int f3(unsigned char c, unsigned char d) __z88dk_callee __smallc __reentrant
18 return c + d;
21 #if !defined(__SDCC_hc08) && !defined(__SDCC_s08) && !defined(__SDCC_mos6502) && !defined(__SDCC_mos65c02)
22 unsigned long int f4(unsigned long int c) __z88dk_callee
23 #else
24 unsigned long int f4(unsigned long int c) __z88dk_callee __reentrant
25 #endif
27 return c + 1;
30 unsigned char (*p1)(unsigned char) __z88dk_callee;
31 unsigned int (*p2)(unsigned int) __z88dk_callee;
32 unsigned int (*p3)(unsigned char, unsigned char) __z88dk_callee __smallc __reentrant;
33 #if !defined(__SDCC_hc08) && !defined(__SDCC_s08) && !defined(__SDCC_mos6502) && !defined(__SDCC_mos65c02)
34 unsigned long int (*p4)(unsigned long int) __z88dk_callee;
35 #else
36 unsigned long int (*p4)(unsigned long int) __z88dk_callee __reentrant;
37 #endif
39 int j;
41 void g0(void)
43 j++;
46 void g1(int i) __z88dk_callee
48 j = i;
49 g0(); // Tail call optimization needs to do extra work here, to avoid skipping stack cleanup.
52 void
53 testZ88dk(void)
55 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15)
56 ASSERT (f1 (23) == 24);
57 ASSERT (f2 (23) == 24);
58 ASSERT (f3 (23, 42) == 65);
59 ASSERT (f4 (23) == 24);
61 p1 = &f1;
62 p2 = &f2;
63 p3 = &f3;
64 p4 = &f4;
66 ASSERT ((*p1) (23) == 24);
67 ASSERT ((*p2) (23) == 24);
68 ASSERT ((*p3) (23, 42) == 65);
69 ASSERT ((*p4) (23) == 24);
70 #endif
72 g1(1);
73 ASSERT (j == 2);