Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-divmod-1.c
blobda81b996850b7832ea9372c4cfb20e7b83bd0306
1 /*
2 divmod-1.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #endif
11 int
12 div1 (signed char x)
14 return x / -1;
17 int
18 div2 (signed short x)
20 return x / -1;
23 int
24 div3 (signed char x, signed char y)
26 return x / y;
29 int
30 div4 (signed short x, signed short y)
32 return x / y;
35 int
36 mod1 (signed char x)
38 return x % -1;
41 int
42 mod2 (signed short x)
44 return x % -1;
47 int
48 mod3 (signed char x, signed char y)
50 return x % y;
53 int
54 mod4 (signed short x, signed short y)
56 return x % y;
59 #ifndef __SDCC_pdk14 // Lack of memory
60 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
61 signed long
62 mod5 (signed long x, signed long y)
64 return x % y;
67 unsigned long
68 mod6 (unsigned long x, unsigned long y)
70 return x % y;
72 #endif
73 #endif
75 void
76 testTortureExecute (void)
78 ASSERT(!(div1 (-(1 << 7)) != 1 << 7));
79 ASSERT(!(div2 (-(1 << 15)) != 1 << 15));
80 ASSERT(!(div3 (-(1 << 7), -1) != 1 << 7));
81 ASSERT(!(div4 (-(1 << 15), -1) != 1 << 15));
82 ASSERT(!(mod1 (-(1 << 7)) != 0));
83 ASSERT(!(mod2 (-(1 << 15)) != 0));
84 ASSERT(!(mod3 (-(1 << 7), -1) != 0));
85 ASSERT(!(mod4 (-(1 << 15), -1) != 0));
86 #ifndef __SDCC_pdk14 // Lack of memory
87 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
88 ASSERT(!(mod5 (0x50000000, 2) != 0));
89 ASSERT(!(mod6 (0x50000000, 2) != 0));
90 #endif
91 #endif
93 return;