gcc/testsuite/gcc.dg/pr20115.c
raw| 1 | /* { dg-do run } */ |
| 2 | /* { dg-options "-O2" } */ |
| 3 | |
| 4 | int func_pure (void); |
| 5 | void func_other (int); |
| 6 | int global_int; |
| 7 | int func_pure (void) { return global_int; } |
| 8 | void func_other (int a) |
| 9 | { |
| 10 | global_int = a + 1; |
| 11 | } |
| 12 | int f(void) |
| 13 | { |
| 14 | int a; |
| 15 | a = func_pure(); |
| 16 | func_other (a); |
| 17 | a = func_pure (); // We were removing this function call |
| 18 | return a; |
| 19 | } |
| 20 | void abort (void); |
| 21 | |
| 22 | int main(void) |
| 23 | { |
| 24 | global_int = 10; |
| 25 | if (f() != 11) |
| 26 | abort (); |
| 27 | return 0; |
| 28 | } |