URL
https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk
Only display areas with differences |
Details |
Blame |
View Log
Rev 301 |
Rev 384 |
// Test PR 17400. Test case provided by Serge Belyshev.
|
// Test PR 17400. Test case provided by Serge Belyshev.
|
|
|
/* { dg-do compile } */
|
/* { dg-do compile } */
|
/* { dg-options "-O1" } */
|
/* { dg-options "-O1" } */
|
|
|
|
|
void inc (int &);
|
void inc (int &);
|
bool dec_test (int &);
|
bool dec_test (int &);
|
|
|
struct A
|
struct A
|
{
|
{
|
int c;
|
int c;
|
|
|
friend void AddRef (A * p)
|
friend void AddRef (A * p)
|
{
|
{
|
inc (p->c);
|
inc (p->c);
|
}
|
}
|
|
|
friend void Release (A * p)
|
friend void Release (A * p)
|
{
|
{
|
if(dec_test (p->c))
|
if(dec_test (p->c))
|
delete p;
|
delete p;
|
}
|
}
|
};
|
};
|
|
|
struct B
|
struct B
|
{
|
{
|
B (A *p) : obj(p)
|
B (A *p) : obj(p)
|
{
|
{
|
AddRef (obj);
|
AddRef (obj);
|
}
|
}
|
|
|
~B()
|
~B()
|
{
|
{
|
Release (obj);
|
Release (obj);
|
}
|
}
|
|
|
void swap (B &rhs)
|
void swap (B &rhs)
|
{
|
{
|
A * tmp = obj;
|
A * tmp = obj;
|
obj = rhs.obj;
|
obj = rhs.obj;
|
rhs.obj = tmp;
|
rhs.obj = tmp;
|
}
|
}
|
|
|
A *obj;
|
A *obj;
|
};
|
};
|
|
|
void bar (A *p1, A* p2)
|
void bar (A *p1, A* p2)
|
{
|
{
|
B px (p1);
|
B px (p1);
|
B px2 (p2);
|
B px2 (p2);
|
px.swap (px2);
|
px.swap (px2);
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.