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-loop-15.c
blob5dd882d3c751663c18f411e0c4fbbef2e6f37c2c
1 /*
2 loop-15.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 /* Bombed with a segfault on powerpc-linux. doloop.c generated wrong
12 loop count. */
13 void
14 foo (unsigned long *start, unsigned long *end)
16 unsigned long *temp = end - 1;
18 while (end > start)
19 *end-- = *temp--;
22 void
23 testTortureExecute (void)
25 #ifndef __SDCC_pdk14 // Lack of memory
26 unsigned long a[5];
27 int start, end, k;
29 for (start = 0; start < 5; start++)
30 for (end = 0; end < 5; end++)
32 for (k = 0; k < 5; k++)
33 a[k] = k;
35 foo (a + start, a + end);
37 for (k = 0; k <= start; k++)
38 if (a[k] != k)
39 ASSERT (0);
41 for (k = start + 1; k <= end; k++)
42 if (a[k] != k - 1)
43 ASSERT (0);
45 for (k = end + 1; k < 5; k++)
46 if (a[k] != k)
47 ASSERT (0);
49 #endif
50 return;