Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / bug-3711.c
blobf0b0dc742000f110b3403a860e982356c1678833
1 /* bug-3711.c
2 A bug in mcs51 code generation for __reentrant functions with __bit parameters.
3 */
5 #include <testfwk.h>
7 #if !defined(__SDCC_mcs51) && !defined(__SDCC_ds390)
8 #define __bit _Bool
9 #endif
11 void f0(__bit b) __reentrant;
12 void f1(unsigned char c, __bit b) __reentrant;
13 void f2(__bit b, unsigned char c) __reentrant;
14 void f3(unsigned long long l, __bit b) __reentrant;
15 void f4(__bit b, unsigned long long l) __reentrant;
16 void f5 (unsigned char c, const unsigned char __code* cp, unsigned int i, unsigned int j, __bit b, const void __code* vcp) __reentrant;
18 void g(void)
20 f0(0);
21 f1(1, 0);
22 f2(0, 1);
23 f3(1, 0);
24 #ifndef __SDCC_mcs51 // Bug #3712
25 f4(0, 1);
26 #endif
27 f5(2, 0, 3, 4, 1, 0);
30 void
31 testBug(void)
33 g();
36 void f0(__bit b) __reentrant
38 ASSERT (b == 0);
41 void f1(unsigned char c, __bit b) __reentrant
43 ASSERT (c == 1);
44 ASSERT (b == 0);
47 void f2(__bit b, unsigned char c) __reentrant
49 ASSERT (b == 0);
50 ASSERT (c == 1);
53 void f3(unsigned long long l, __bit b) __reentrant
55 ASSERT (l == 1);
56 ASSERT (b == 0);
59 #ifndef __SDCC_mcs51 // Bug #3712
60 void f4(__bit b, unsigned long long l) __reentrant
62 ASSERT (b == 0);
63 ASSERT (l == 1);
65 #endif
67 void f5 (unsigned char c, const unsigned char __code* cp, unsigned int i, unsigned int j, __bit b, const void __code* vcp) __reentrant
69 ASSERT (c == 2);
70 ASSERT (cp == 0);
71 ASSERT (i == 3);
72 ASSERT (j == 4);
73 ASSERT (b == 1);
74 ASSERT (vcp == 0);