| 1 |
// PR c++/52643 |
| 2 |
// { dg-options "-O" } |
| 3 |
|
| 4 |
template<class T> class already_AddRefd {}; |
| 5 |
|
| 6 |
template<class T> |
| 7 |
class ObjRef |
| 8 |
{ |
| 9 |
public: |
| 10 |
ObjRef() {} |
| 11 |
|
| 12 |
ObjRef(const already_AddRefd<T> aar) {} |
| 13 |
|
| 14 |
~ObjRef() |
| 15 |
{ |
| 16 |
T* mPtr; |
| 17 |
mPtr->release_ref(); |
| 18 |
} |
| 19 |
|
| 20 |
operator T* () const |
| 21 |
{ |
| 22 |
return __null; |
| 23 |
} |
| 24 |
|
| 25 |
template<class U> |
| 26 |
void operator= (const already_AddRefd<U>& newAssign) {} |
| 27 |
}; |
| 28 |
|
| 29 |
class MyRetClass { |
| 30 |
public: |
| 31 |
void release_ref(); |
| 32 |
}; |
| 33 |
|
| 34 |
class MyClass |
| 35 |
{ |
| 36 |
void appendChild(); |
| 37 |
void getTripleOutOfByPredicate(); |
| 38 |
already_AddRefd<MyRetClass> getNextTriple(); |
| 39 |
}; |
| 40 |
|
| 41 |
void |
| 42 |
MyClass::getTripleOutOfByPredicate() |
| 43 |
{ |
| 44 |
ObjRef<MyRetClass> t (getNextTriple()); |
| 45 |
|
| 46 |
if (t == __null) |
| 47 |
throw MyRetClass(); |
| 48 |
} |
| 49 |
|
| 50 |
void |
| 51 |
MyClass::appendChild() |
| 52 |
{ |
| 53 |
while (1) |
| 54 |
{ |
| 55 |
try |
| 56 |
{ |
| 57 |
ObjRef<MyRetClass> t (getNextTriple()); |
| 58 |
continue; |
| 59 |
} |
| 60 |
catch (MyRetClass) |
| 61 |
{ |
| 62 |
} |
| 63 |
} |
| 64 |
} |