gcc/testsuite/gcc.c-torture/execute/pr54985.c
raw| 1 | |
| 2 | typedef struct st { |
| 3 | int a; |
| 4 | } ST; |
| 5 | |
| 6 | int __attribute__((noinline,noclone)) |
| 7 | foo(ST *s, int c) |
| 8 | { |
| 9 | int first = 1; |
| 10 | int count = c; |
| 11 | ST *item = s; |
| 12 | int a = s->a; |
| 13 | int x; |
| 14 | |
| 15 | while (count--) |
| 16 | { |
| 17 | x = item->a; |
| 18 | if (first) |
| 19 | first = 0; |
| 20 | else if (x >= a) |
| 21 | return 1; |
| 22 | a = x; |
| 23 | item++; |
| 24 | } |
| 25 | return 0; |
| 26 | } |
| 27 | |
| 28 | extern void abort (void); |
| 29 | |
| 30 | int main () |
| 31 | { |
| 32 | ST _1[2] = {{2}, {1}}; |
| 33 | if (foo(_1, 2) != 0) |
| 34 | abort (); |
| 35 | return 0; |
| 36 | } |