struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-divconst-2.c
blob4f89ce935b38a017dd9634de10db37053807e35f
1 /*
2 divconst-2.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 #pragma disable_warning 85
13 #ifndef __SDCC_pdk14 // Lack of memory
14 long
15 f (long x)
17 return x / (-0x7fffffffL - 1L);
20 long
21 r (long x)
23 return x % (-0x7fffffffL - 1L);
26 #if !(defined(__SDCC_pic14) && !defined(__SDCC_PIC14_ENHANCED)) // Pseudo-stack size limit
27 /* Since we have a negative divisor, this equation must hold for the
28 results of / and %; no specific results are guaranteed. */
29 long
30 std_eqn (long num, long denom, long quot, long rem)
32 /* For completeness, a check for "ABS (rem) < ABS (denom)" belongs here,
33 but causes trouble on 32-bit machines and isn't worthwhile. */
34 return quot * (-0x7fffffffL - 1L) + rem == num;
36 #endif
38 long nums[] =
40 -1L, 0x7fffffffL, -0x7fffffffL - 1L
42 #endif
44 void
45 testTortureExecute (void)
47 #ifndef __SDCC_pdk14 // Lack of memory
48 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
49 int i;
51 for (i = 0;
52 i < sizeof (nums) / sizeof (nums[0]);
53 i++)
54 #if !(defined(__SDCC_pic14) && !defined(__SDCC_PIC14_ENHANCED)) // Pseudo-stack size limit
55 if (std_eqn (nums[i], -0x7fffffffL - 1L, f (nums[i]), r (nums[i])) == 0)
56 ASSERT (0);
57 #endif
58 #endif
59 #endif
60 return;