| 1 |
// { dg-do compile } |
| 2 |
|
| 3 |
template <typename C> struct A |
| 4 |
{ |
| 5 |
typedef typename C::iterator type; |
| 6 |
}; |
| 7 |
template <typename T2> struct B |
| 8 |
{ |
| 9 |
typedef T2 type; |
| 10 |
}; |
| 11 |
template <typename F2> struct L |
| 12 |
{ |
| 13 |
typedef typename B<F2>::type::type type; |
| 14 |
}; |
| 15 |
template <typename C> struct M |
| 16 |
{ |
| 17 |
typedef typename L<A<C> >::type type; |
| 18 |
}; |
| 19 |
class C |
| 20 |
{ |
| 21 |
public: |
| 22 |
typedef int iterator; |
| 23 |
}; |
| 24 |
template <class IteratorT> class D |
| 25 |
{ |
| 26 |
public: |
| 27 |
typedef IteratorT iterator; |
| 28 |
template <class Iterator> D (Iterator p1, Iterator) : m_Begin (p1), m_End (0) |
| 29 |
{ |
| 30 |
} |
| 31 |
IteratorT m_Begin; |
| 32 |
IteratorT m_End; |
| 33 |
}; |
| 34 |
template <class IteratorT> class I : public D<IteratorT> |
| 35 |
{ |
| 36 |
protected: |
| 37 |
template <class Iterator> |
| 38 |
I (Iterator p1, Iterator p2) |
| 39 |
: D<IteratorT> (p1, p2) |
| 40 |
{ |
| 41 |
} |
| 42 |
}; |
| 43 |
class F |
| 44 |
{ |
| 45 |
public: |
| 46 |
int nelems; |
| 47 |
int elems[]; // { dg-error "not at end" } |
| 48 |
int * |
| 49 |
m_fn1 () |
| 50 |
{ |
| 51 |
return elems; |
| 52 |
} |
| 53 |
}; |
| 54 |
class G |
| 55 |
{ |
| 56 |
public: |
| 57 |
void * |
| 58 |
m_fn2 (int) |
| 59 |
{ |
| 60 |
return m_buffer.m_fn1 (); |
| 61 |
} |
| 62 |
F m_buffer; |
| 63 |
}; |
| 64 |
struct any_incrementable_iterator_interface |
| 65 |
{ |
| 66 |
virtual ~any_incrementable_iterator_interface () {} |
| 67 |
}; |
| 68 |
class J : public any_incrementable_iterator_interface |
| 69 |
{ |
| 70 |
public: |
| 71 |
J (int) : m_it () {} |
| 72 |
int m_it; |
| 73 |
}; |
| 74 |
void *operator new(__SIZE_TYPE__, void *p2) { return p2; } |
| 75 |
template <class T> typename M<T>::type begin (T) { return 0; } |
| 76 |
template <class T> typename M<T>::type end (T) {} |
| 77 |
template <class> class any_iterator |
| 78 |
{ |
| 79 |
public: |
| 80 |
template <class WrappedIterator> any_iterator (WrappedIterator) |
| 81 |
{ |
| 82 |
void *ptr = m_buffer.m_fn2 (0); |
| 83 |
m_impl = new (ptr) J (0); |
| 84 |
} |
| 85 |
~any_iterator () |
| 86 |
{ |
| 87 |
if (m_impl) |
| 88 |
m_impl->~any_incrementable_iterator_interface (); |
| 89 |
} |
| 90 |
G m_buffer; |
| 91 |
any_incrementable_iterator_interface *m_impl; // { dg-message "next member" } |
| 92 |
}; |
| 93 |
template <class Reference> class K : public I<any_iterator<Reference> > |
| 94 |
{ |
| 95 |
public: |
| 96 |
template <class WrappedRange> |
| 97 |
K (WrappedRange p1) |
| 98 |
: I<any_iterator<Reference> > (begin (p1), end (p1)) |
| 99 |
{ |
| 100 |
} |
| 101 |
}; |
| 102 |
template <class Reference> struct H |
| 103 |
{ |
| 104 |
typedef K<Reference> type; |
| 105 |
}; |
| 106 |
template <class, class, class, class, class, class TargetReference> |
| 107 |
void |
| 108 |
mix_values_impl () |
| 109 |
{ |
| 110 |
C test_data; |
| 111 |
H<int>::type source_data (test_data); |
| 112 |
typename H<TargetReference>::type t2 = source_data; |
| 113 |
} |
| 114 |
template <class> |
| 115 |
void |
| 116 |
mix_values_driver () |
| 117 |
{ |
| 118 |
mix_values_impl<int, int, int, int, int, int &> (); |
| 119 |
} |
| 120 |
void |
| 121 |
mix_values () |
| 122 |
{ |
| 123 |
mix_values_driver<int> (); |
| 124 |
} |