summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr29801.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/pr29801.c')
-rw-r--r--gcc/testsuite/gcc.dg/pr29801.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/pr29801.c b/gcc/testsuite/gcc.dg/pr29801.c
new file mode 100644
index 000000000..b61ae5142
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr29801.c
@@ -0,0 +1,24 @@
+/* We used to crash in ccp here, because the initial constant value of 2
+ was changed to 5. */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+static const int a = 2;
+
+int test (int param)
+{
+ int *p = (int *) &a;
+
+ if (param)
+ *p = 5;
+
+ return a;
+}
+
+/* Check that we return the correct (unchanged) value. */
+
+/* { dg-final { scan-tree-dump-times "return 2" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "return 5" 0 "optimized" } } */
+
+/* { dg-final { cleanup-tree-dump "optimized" } } */