gcc/testsuite/gcc.c-torture/execute/loop-5.c
raw| 1 | void abort (void); |
| 2 | void exit (int); |
| 3 | |
| 4 | static int ap(int i); |
| 5 | static void testit(void){ |
| 6 | int ir[4] = {0,1,2,3}; |
| 7 | int ix,n,m; |
| 8 | n=1; m=3; |
| 9 | for (ix=1;ix<=4;ix++) { |
| 10 | if (n == 1) m = 4; |
| 11 | else m = n-1; |
| 12 | ap(ir[n-1]); |
| 13 | n = m; |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | static int t = 0; |
| 18 | static int a[4]; |
| 19 | |
| 20 | static int ap(int i){ |
| 21 | if (t > 3) |
| 22 | abort(); |
| 23 | a[t++] = i; |
| 24 | return 1; |
| 25 | } |
| 26 | |
| 27 | int main(void) |
| 28 | { |
| 29 | testit(); |
| 30 | if (a[0] != 0) |
| 31 | abort(); |
| 32 | if (a[1] != 3) |
| 33 | abort(); |
| 34 | if (a[2] != 2) |
| 35 | abort(); |
| 36 | if (a[3] != 1) |
| 37 | abort(); |
| 38 | exit(0); |
| 39 | } |