URL
https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk
Subversion Repositories openrisc_me
[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [g++.dg/] [tree-ssa/] [pr17400.C] - Rev 414
Go to most recent revision | Compare with Previous | Blame | View Log
// Test PR 17400. Test case provided by Serge Belyshev.
/* { dg-do compile } */
/* { dg-options "-O1" } */
void inc (int &);
bool dec_test (int &);
struct A
{
int c;
friend void AddRef (A * p)
{
inc (p->c);
}
friend void Release (A * p)
{
if(dec_test (p->c))
delete p;
}
};
struct B
{
B (A *p) : obj(p)
{
AddRef (obj);
}
~B()
{
Release (obj);
}
void swap (B &rhs)
{
A * tmp = obj;
obj = rhs.obj;
rhs.obj = tmp;
}
A *obj;
};
void bar (A *p1, A* p2)
{
B px (p1);
B px2 (p2);
px.swap (px2);
}
Go to most recent revision | Compare with Previous | Blame | View Log