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-pr24716.c
blob775ea9bb8b0f94c5f0e4870db3df78c0dd6ce67f
1 /*
2 pr24716.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 /* PR24716, scalar evolution returning the wrong result
12 for pdest. */
14 int Link[] = { -1 };
15 int W[] = { 2 };
17 int f (int k, int p)
19 int pdest, j, D1361;
20 j = 0;
21 pdest = 0;
22 for (;;) {
23 if (pdest > 2)
25 j--, pdest++;
26 while (j > 2);
28 if (j == 1)
29 break;
31 while (pdest > p)
32 if (j == p)
33 pdest++;
37 D1361 = W[k];
39 if (D1361 != 0)
40 pdest = 1, W[k] = D1361 = 0;
41 while (p < 1);
42 } while (k > 0);
46 p = 0;
47 k = Link[k];
48 while (p < j)
49 if (k != -1)
50 pdest++, p++;
52 while (k != -1);
53 j = 1;
56 /* The correct return value should be pdest (1 in the call from main).
57 DOM3 is mistaken and propagates a 0 here. */
58 return pdest;
61 void
62 testTortureExecute (void)
64 if (!f (0, 2))
65 ASSERT (0);
66 return;