aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-ptrarith-1.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-ptrarith-1.c')
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-ptrarith-1.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-ptrarith-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-ptrarith-1.c
new file mode 100644
index 000000000..ab5634da9
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/torture/pta-ptrarith-1.c
@@ -0,0 +1,33 @@
+/* { dg-do run } */
+/* { dg-options "-fdump-tree-alias" } */
+/* { dg-skip-if "" { *-*-* } { "-O0" "-fno-fat-lto-objects" } { "" } } */
+
+struct Foo {
+ int *p;
+};
+
+void __attribute__((noinline))
+foo (void *p)
+{
+ struct Foo *f = (struct Foo *)p - 1;
+ *f->p = 0;
+}
+
+int bar (void)
+{
+ struct Foo f;
+ int i = 1;
+ f.p = &i;
+ foo (&f + 1);
+ return i;
+}
+extern void abort (void);
+int main()
+{
+ if (bar () != 0)
+ abort ();
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump "ESCAPED = {\[^\n\}\]* i f \[^\n\}\]*}" "alias" } } */
+/* { dg-final { cleanup-tree-dump "alias" } } */