aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr20115.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/pr20115.c')
-rw-r--r--gcc/testsuite/gcc.dg/pr20115.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/pr20115.c b/gcc/testsuite/gcc.dg/pr20115.c
new file mode 100644
index 00000000000..cea4b486854
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr20115.c
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+int func_pure (void);
+void func_other (int);
+int global_int;
+int func_pure (void) { return global_int; }
+void func_other (int a)
+{
+ global_int = a + 1;
+}
+int f(void)
+{
+ int a;
+ a = func_pure();
+ func_other (a);
+ a = func_pure (); // We were removing this function call
+ return a;
+}
+void abort (void);
+
+int main(void)
+{
+ global_int = 10;
+ if (f() != 11)
+ abort ();
+ return 0;
+}