aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2005-12-08 22:50:38 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2005-12-08 22:50:38 +0100
commit6d66414c171c195ac821aa54f35234542759be5b (patch)
tree6d2cb5bbd0c9cfd0f6ab7c8254a6f761b4ff0efa /gcc
parent1412e0b515a094e32d68c6460708fbc8ff79e0ef (diff)
downloadgcc-6d66414c171c195ac821aa54f35234542759be5b.zip
gcc-6d66414c171c195ac821aa54f35234542759be5b.tar.gz
gcc-6d66414c171c195ac821aa54f35234542759be5b.tar.bz2
re PR c++/19317 (removing a temporary return value when we cannot)
PR c++/19317 * g++.dg/opt/pr19317-1.C: New test. * g++.dg/opt/pr19317-2.C: New test. * g++.dg/opt/pr19317-3.C: New test. From-SVN: r108247
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/opt/pr19317-1.C39
-rw-r--r--gcc/testsuite/g++.dg/opt/pr19317-2.C32
-rw-r--r--gcc/testsuite/g++.dg/opt/pr19317-3.C37
4 files changed, 113 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9587082..0697eb8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2005-12-08 Jakub Jelinek <jakub@redhat.com>
+ PR c++/19317
+ * g++.dg/opt/pr19317-1.C: New test.
+ * g++.dg/opt/pr19317-2.C: New test.
+ * g++.dg/opt/pr19317-3.C: New test.
+
PR target/19005
* gcc.c-torture/execute/pr19005.c: New test.
diff --git a/gcc/testsuite/g++.dg/opt/pr19317-1.C b/gcc/testsuite/g++.dg/opt/pr19317-1.C
new file mode 100644
index 0000000..ffb646a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr19317-1.C
@@ -0,0 +1,39 @@
+// PR c++/19317
+// { dg-options "-O2" }
+// { dg-do run }
+// Origin: Dirk Mueller <mueller@kde.org>
+
+extern "C" void abort (void);
+
+struct A
+{
+ A () { d = e = 0; f = -1; }
+ A (int x) : d (0), e (0), f (x) { }
+ A b (const A &r) const;
+ int d;
+ int e;
+ int f;
+};
+
+A
+A::b (const A & r) const
+{
+ A t;
+ t.f = f < r.f ? f : r.f;
+ return t;
+}
+
+int
+main ()
+{
+ A a (100);
+ a = a.b (A (10));
+ if (a.f != 10)
+ abort ();
+
+ A c (10);
+ A d (100);
+ c = d.b (c);
+ if (c.f != 10)
+ abort ();
+}
diff --git a/gcc/testsuite/g++.dg/opt/pr19317-2.C b/gcc/testsuite/g++.dg/opt/pr19317-2.C
new file mode 100644
index 0000000..70c642b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr19317-2.C
@@ -0,0 +1,32 @@
+// PR c++/19317
+// { dg-options "-O2" }
+// { dg-do run }
+
+extern "C" void abort (void);
+
+struct A
+{
+ A () { d = e = 0; f = -1; }
+ A (int x) : d (0), e (0), f (x) { }
+ A b () const;
+ int d;
+ int e;
+ int f;
+};
+
+A
+A::b () const
+{
+ A t;
+ t.f = 10 + this->f;
+ return t;
+}
+
+int
+main ()
+{
+ A a (100);
+ a = a.b ();
+ if (a.f != 110)
+ abort ();
+}
diff --git a/gcc/testsuite/g++.dg/opt/pr19317-3.C b/gcc/testsuite/g++.dg/opt/pr19317-3.C
new file mode 100644
index 0000000..b2b2bb0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr19317-3.C
@@ -0,0 +1,37 @@
+// PR c++/19317
+// { dg-options "-O2" }
+// { dg-do run }
+
+extern "C" void abort (void);
+
+struct A { int c; int d; int e; int f; };
+
+A
+foo (const A *x, const A *r)
+{
+ A t;
+ t.c = -1;
+ t.c += x->c < r->c ? x->c : r->c;
+ t.d = 0;
+ t.e = 0;
+ t.f = 0;
+ return t;
+}
+
+int
+main ()
+{
+ A a;
+ a.c = 10;
+ a.d = 0;
+ a.e = 0;
+ a.f = 0;
+ A b;
+ b.c = 100;
+ b.d = 0;
+ b.e = 0;
+ b.f = 0;
+ a = foo (&b, &a);
+ if (a.c != 9)
+ abort ();
+}