Commit 6d66414c by Jakub Jelinek Committed by Jakub Jelinek

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
parent 1412e0b5
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.
// 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 ();
}
// 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 ();
}
// 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 ();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment