URL
https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk
Only display areas with differences |
Details |
Blame |
View Log
Rev 149 |
Rev 154 |
// { dg-do run }
|
// { dg-do run }
|
// GROUPS passed temps
|
// GROUPS passed temps
|
// temps file
|
// temps file
|
// Message-Id: <9212181914.AA05066@sparc1.cnm.us.es>
|
// Message-Id: <9212181914.AA05066@sparc1.cnm.us.es>
|
// From: juando@cnm.us.es (Juan Domingo Martin Gomez)
|
// From: juando@cnm.us.es (Juan Domingo Martin Gomez)
|
// Subject: Temporaries destroyed too soon
|
// Subject: Temporaries destroyed too soon
|
// Date: Fri, 18 Dec 92 20:14:45 +0100
|
// Date: Fri, 18 Dec 92 20:14:45 +0100
|
|
|
#include
|
#include
|
|
|
int status = 0;
|
int status = 0;
|
int fail = 0;
|
int fail = 0;
|
|
|
class Foo
|
class Foo
|
{
|
{
|
public:
|
public:
|
Foo();
|
Foo();
|
~Foo();
|
~Foo();
|
|
|
Foo &method();
|
Foo &method();
|
};
|
};
|
|
|
Foo f1()
|
Foo f1()
|
{
|
{
|
return Foo();
|
return Foo();
|
}
|
}
|
|
|
Foo::Foo()
|
Foo::Foo()
|
{
|
{
|
}
|
}
|
|
|
Foo::~Foo()
|
Foo::~Foo()
|
{
|
{
|
if (status == 2)
|
if (status == 2)
|
fail = 0;
|
fail = 0;
|
else
|
else
|
fail = 1;
|
fail = 1;
|
}
|
}
|
|
|
Foo &Foo::method()
|
Foo &Foo::method()
|
{
|
{
|
status++;
|
status++;
|
return *this;
|
return *this;
|
}
|
}
|
|
|
int main()
|
int main()
|
{
|
{
|
// f1() returns a temporary object. The member function
|
// f1() returns a temporary object. The member function
|
// method() returns a reference to the same object.
|
// method() returns a reference to the same object.
|
f1().method().method();
|
f1().method().method();
|
if (fail)
|
if (fail)
|
{ printf ("FAIL\n"); return 1; }
|
{ printf ("FAIL\n"); return 1; }
|
else
|
else
|
printf ("PASS\n");
|
printf ("PASS\n");
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.