From 86e39aa349be40eef56805b07f413afee5eaa761 Mon Sep 17 00:00:00 2001 From: jakub Date: Thu, 8 Dec 2005 21:50:38 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@108247 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/opt/pr19317-1.C | 39 ++++++++++++++++++++++++++++++++++++ gcc/testsuite/g++.dg/opt/pr19317-2.C | 32 +++++++++++++++++++++++++++++ gcc/testsuite/g++.dg/opt/pr19317-3.C | 37 ++++++++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 gcc/testsuite/g++.dg/opt/pr19317-1.C create mode 100644 gcc/testsuite/g++.dg/opt/pr19317-2.C create mode 100644 gcc/testsuite/g++.dg/opt/pr19317-3.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 958708256a5..0697eb82d1e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2005-12-08 Jakub Jelinek + 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 00000000000..ffb646a9097 --- /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 + +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 00000000000..70c642b219d --- /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 00000000000..b2b2bb0e99c --- /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 (); +} -- 2.11.4.GIT