PR c++/19317
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 8 Dec 2005 21:50:38 +0000 (21:50 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 8 Dec 2005 21:50:38 +0000 (21:50 +0000)
* 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

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr19317-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/opt/pr19317-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/opt/pr19317-3.C [new file with mode: 0644]

index 9587082..0697eb8 100644 (file)
@@ -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 (file)
index 0000000..ffb646a
--- /dev/null
@@ -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 (file)
index 0000000..70c642b
--- /dev/null
@@ -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 (file)
index 0000000..b2b2bb0
--- /dev/null
@@ -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 ();
+}