OSDN Git Service

2010-02-15 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / torture / pr35164-1.C
1 typedef __SIZE_TYPE__ size_t;
2 template<typename _Iterator, typename _Container> class __normal_iterator {
3 public:
4   const _Iterator& base() const;
5 };
6 template<typename _BI1, typename _BI2> inline
7 void copy_backward(_BI1 __first, _BI1 __last, _BI2 __result) {
8   while (__first != __last) *--__result = *--__last;
9 }
10 template<typename _Tp> struct _Vector_base {
11   struct _Vector_impl { _Tp* _M_finish; };
12   _Vector_impl _M_impl;
13 };
14 template<typename _Tp > class vector : protected _Vector_base<_Tp> {
15   typedef vector<_Tp> vector_type;
16   typedef _Tp * pointer;
17   typedef _Tp & reference;
18   typedef __normal_iterator<pointer, vector_type> iterator;
19   typedef size_t size_type;
20 public:
21   iterator end();
22   void resize(size_type __new_size) { insert(end(), __new_size); }
23   reference operator[](size_type __n);
24   void insert(iterator __position, size_type __n)
25   {
26     pointer __old_finish(this->_M_impl._M_finish);
27     copy_backward(__position.base(), __old_finish - __n, __old_finish);
28   }
29 };
30 struct A {
31   virtual ~A ();
32   void incRef ();
33   void decRef ();
34 };
35 struct C : public A {
36   static C *alloc ();
37 };
38 template <class T> struct B {
39   B () : ptr (T::alloc ()) { }
40   B (T *a_ptr) : ptr (a_ptr) { }
41   ~B () { decRef (); }
42   B& operator= (const B<T>& a) { if (a.get () != this->get ()) { decRef ();
43 incRef (); } }
44   template<class U> operator B<U> () const { return B<U> (ptr); }
45   T* operator-> () const { }
46   T* get () const { return ptr; }
47   void decRef () const { if (ptr != 0) ptr->decRef (); }
48   void incRef () const { if (ptr != 0) ptr->incRef (); }
49   T *ptr;
50 };
51 struct D : public C {
52   template <class T> inline void foo (const B<T> & x) { d.resize (1); d[0] = x;
53 }
54   vector<B <C> > d;
55 };
56 struct E : public C {
57   static E *alloc ();
58 };
59 struct F : public D {
60   static F *alloc ();
61 };
62 void foo (vector<B<D> > & x) {
63   for (int i = 0; i < 2; ++i)
64     {
65       B<F> l;
66       B<E> m;
67       l->foo (m);
68     }
69 }