summaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2010-07-26 16:01:55 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2010-07-26 16:01:55 +0000
commit095a3ce9a2b69eeaae28ea51c1cbbd1322ee291d (patch)
tree4dd9226e46cf61e9b8b0ed19dc32773d0e0121c8 /gcc/testsuite
parenta70dabf5840130eb9caeb7000a148c3f1bfcd812 (diff)
downloadgcc-095a3ce9a2b69eeaae28ea51c1cbbd1322ee291d.tar.gz
2010-07-26 Richard Guenther <rguenther@suse.de>
PR tree-optimization/43784 * tree-nrv.c (dest_safe_for_nrv_p): It's not safe to NRV if the destination is used by the call. * gcc.c-torture/execute/pr43784.c: New testcase. * g++.dg/torture/pr43784.C: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162539 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/torture/pr43784.C24
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr43784.c33
3 files changed, 63 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 52d94d2166d..cd7de607c77 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,11 @@
2010-07-26 Richard Guenther <rguenther@suse.de>
+ PR tree-optimization/43784
+ * gcc.c-torture/execute/pr43784.c: New testcase.
+ * g++.dg/torture/pr43784.C: Likewise.
+
+2010-07-26 Richard Guenther <rguenther@suse.de>
+
PR middle-end/45056
* g++.dg/pr45056.C: New testcase.
diff --git a/gcc/testsuite/g++.dg/torture/pr43784.C b/gcc/testsuite/g++.dg/torture/pr43784.C
new file mode 100644
index 00000000000..a83a6f374d7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr43784.C
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+/* { dg-options "-fno-tree-sra" } */
+
+struct S {int x, y, makemelarge[5];};
+S __attribute__((noinline)) f (S &s) {
+ S r;
+ r.x = s.y;
+ r.y = s.x;
+ return r;
+}
+int __attribute__((noinline)) glob (int a, int b)
+{
+ S local = { a, b };
+ local = f (local);
+ return local.y;
+}
+extern "C" void abort (void);
+int main (void)
+{
+ if (glob (1, 3) != 1)
+ abort ();
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr43784.c b/gcc/testsuite/gcc.c-torture/execute/pr43784.c
new file mode 100644
index 00000000000..622232725a2
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr43784.c
@@ -0,0 +1,33 @@
+struct s {
+ unsigned char a[256];
+};
+union u {
+ struct { struct s b; int c; } d;
+ struct { int c; struct s b; } e;
+};
+
+static union u v;
+static struct s *p = &v.d.b;
+static struct s *q = &v.e.b;
+
+static struct s __attribute__((noinline)) rp(void)
+{
+ return *p;
+}
+
+static void qp(void)
+{
+ *q = rp();
+}
+
+int main()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ p->a[i] = i;
+ qp();
+ for (i = 0; i < 256; i++)
+ if (q->a[i] != i)
+ __builtin_abort();
+ return 0;
+}