| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-additional-options "-Wno-return-type" } */ |
| 3 |
|
| 4 |
template <typename _Tp> _Tp *__addressof(_Tp &) {} |
| 5 |
template <typename _Tp> class A { |
| 6 |
public: |
| 7 |
typedef _Tp *pointer; |
| 8 |
}; |
| 9 |
template <typename _Tp> class M : public A<_Tp> { |
| 10 |
public: |
| 11 |
typedef M other; |
| 12 |
~M(); |
| 13 |
}; |
| 14 |
class B { |
| 15 |
public: |
| 16 |
B(int *); |
| 17 |
}; |
| 18 |
class C { |
| 19 |
public: |
| 20 |
void GetNext(); |
| 21 |
C *GetChildren(); |
| 22 |
}; |
| 23 |
template <typename _Tp> void _Destroy(_Tp *p1) { p1->~_Tp(); } |
| 24 |
struct D { |
| 25 |
template <typename _ForwardIterator> |
| 26 |
static void __destroy(_ForwardIterator p1, _ForwardIterator p2) { |
| 27 |
for (; p1 != p2; ++p1) |
| 28 |
_Destroy(__addressof(*p1)); |
| 29 |
} |
| 30 |
}; |
| 31 |
template <typename _ForwardIterator> |
| 32 |
void _Destroy(_ForwardIterator p1, _ForwardIterator p2) { |
| 33 |
D::__destroy(p1, p2); |
| 34 |
} |
| 35 |
template <typename _ForwardIterator, typename _Tp> |
| 36 |
void _Destroy(_ForwardIterator p1, _ForwardIterator p2, M<_Tp> &) { |
| 37 |
_Destroy(p1, p2); |
| 38 |
} |
| 39 |
template <typename _Alloc> struct F { |
| 40 |
typedef _Alloc _Tp_alloc_type; |
| 41 |
typedef typename _Tp_alloc_type::pointer pointer; |
| 42 |
struct N : _Tp_alloc_type { |
| 43 |
pointer _M_start; |
| 44 |
pointer _M_finish; |
| 45 |
}; |
| 46 |
_Tp_alloc_type &_M_get_Tp_allocator(); |
| 47 |
N _M_impl; |
| 48 |
}; |
| 49 |
template <typename _Tp, typename _Alloc = M<_Tp> > class O : F<_Alloc> { |
| 50 |
using F<_Alloc>::_M_get_Tp_allocator; |
| 51 |
public: |
| 52 |
~O() { |
| 53 |
_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, |
| 54 |
_M_get_Tp_allocator()); |
| 55 |
} |
| 56 |
}; |
| 57 |
template <class T> void checked_delete(T *p1) { delete p1; } |
| 58 |
template <class> class I; |
| 59 |
template <class T> struct J { |
| 60 |
typedef T *type; |
| 61 |
}; |
| 62 |
class K; |
| 63 |
class L { |
| 64 |
public: |
| 65 |
virtual ~L(); |
| 66 |
}; |
| 67 |
class P : L { |
| 68 |
O<I<int> > databasesM; |
| 69 |
O<I<K> > usersM; |
| 70 |
public: |
| 71 |
I<int> addDatabase(); |
| 72 |
}; |
| 73 |
C a; |
| 74 |
C *b; |
| 75 |
int atomic_exchange_and_add(); |
| 76 |
class G { |
| 77 |
public: |
| 78 |
virtual void dispose() = 0; |
| 79 |
void release() { |
| 80 |
if (atomic_exchange_and_add() == 1) |
| 81 |
dispose(); |
| 82 |
} |
| 83 |
}; |
| 84 |
class Q : G { |
| 85 |
P *px_; |
| 86 |
Q() {} |
| 87 |
void dispose() { checked_delete(px_); } |
| 88 |
}; |
| 89 |
class H { |
| 90 |
G *pi_; |
| 91 |
public: |
| 92 |
H(); |
| 93 |
H(P *); |
| 94 |
~H() { |
| 95 |
if (pi_) |
| 96 |
pi_->release(); |
| 97 |
} |
| 98 |
}; |
| 99 |
template <class T, class Y> void sp_pointer_construct(I<T> *, Y, H); |
| 100 |
template <class T> class I { |
| 101 |
public: |
| 102 |
typedef T element_type; |
| 103 |
template <class Y> I(Y *p1) { sp_pointer_construct(this, 0, 0); } |
| 104 |
typename J<T>::type operator->(); |
| 105 |
H pn; |
| 106 |
}; |
| 107 |
void getNodeContent(const B &) { |
| 108 |
for (C *n = a.GetChildren(); n; n->GetNext()) |
| 109 |
; |
| 110 |
} |
| 111 |
void parseDatabase(I<P> p1) { |
| 112 |
I<int> c = p1->addDatabase(); |
| 113 |
for (; b;) |
| 114 |
getNodeContent(0); |
| 115 |
} |
| 116 |
void addServer() { I<int>(new P); } |