* g++.dg/opt/pr19317-1.C: New test.
* g++.dg/opt/pr19317-2.C: New test.
* g++.dg/opt/pr19317-3.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@108247
138bc75d-0d04-0410-961f-
82ee72b054a4
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.
--- /dev/null
+// 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 ();
+}
--- /dev/null
+// 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 ();
+}
--- /dev/null
+// 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 ();
+}