aboutsummaryrefslogtreecommitdiff
path: root/SingleSource/Regression/C/gcc-c-torture/execute/pr49279.c
diff options
context:
space:
mode:
Diffstat (limited to 'SingleSource/Regression/C/gcc-c-torture/execute/pr49279.c')
-rw-r--r--SingleSource/Regression/C/gcc-c-torture/execute/pr49279.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/SingleSource/Regression/C/gcc-c-torture/execute/pr49279.c b/SingleSource/Regression/C/gcc-c-torture/execute/pr49279.c
new file mode 100644
index 00000000..7f2c0d22
--- /dev/null
+++ b/SingleSource/Regression/C/gcc-c-torture/execute/pr49279.c
@@ -0,0 +1,35 @@
+/* PR tree-optimization/49279 */
+extern void abort (void);
+
+struct S { int a; int *__restrict p; };
+
+__attribute__((noinline, noclone))
+struct S *bar (struct S *p)
+{
+ struct S *r;
+ asm volatile ("" : "=r" (r) : "0" (p) : "memory");
+ return r;
+}
+
+__attribute__((noinline, noclone))
+int
+foo (int *p, int *q)
+{
+ struct S s, *t;
+ s.a = 1;
+ s.p = p;
+ t = bar (&s);
+ t->p = q;
+ s.p[0] = 0;
+ t->p[0] = 1;
+ return s.p[0];
+}
+
+int
+main ()
+{
+ int a, b;
+ if (foo (&a, &b) != 1)
+ abort ();
+ return 0;
+}