* arm.c (FL_WBUF): Define.
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.brendan / crash56.C
blob57c7c11480bdd91a447ee97da9a18fb0019826e2
1 // { dg-do assemble  }
2 // { dg-options "" }
3 // GROUPS passed old-abort
5 const bool FALSE = 0;
6 const bool TRUE = 1;
7 class ListDProto {
8 protected:
9     class link;
10 public:
11     ListDProto();
12     ListDProto(const ListDProto&);
13     virtual ~ListDProto();
14     void operator=(const ListDProto&);
15     unsigned length() const;
16     bool empty() const;
17     void clear();
18     void remove_head();
19     void remove_tail();
20     class Vix {
21     public:
22         Vix();
23         friend int operator==(void *v, const Vix& x) // { dg-error "operator==" }
24             { return v == x.item; }
25         friend int operator==(const Vix& x, void *v) // { dg-error "operator==" }
26             { return v == x.item; }
27         friend int operator!=(void *v, const Vix& x)
28             { return v != x.item; }
29         friend int operator!=(const Vix& x, void *v)
30             { return v != x.item; }
31         friend int operator==(const Vix& x1, const Vix& x2) // { dg-error "operator==" }
32             { return x1.owner == x2.owner && x1.item == x2.item; }
33         friend int operator!=(const Vix& x1, const Vix& x2)
34             { return x1.owner != x2.owner || x1.item != x2.item; }
35         bool first;              
36         bool last;               
37     protected:
38         friend class ListDProto;
39         Vix(const ListDProto *o, link *i);
40         const ListDProto *owner;
41     private:
42         link *item;
43     };
44     enum Action { NORMAL, REMOVE_CURRENT };
45     Vix first() const;
46     void first(Vix& x) const;
47     void next(Vix& x) const;
48     void next(Vix& x, Action a = NORMAL);
49     Vix last() const;
50     void last(Vix& x) const;
51     void prev(Vix& x) const;
52     void prev(Vix& x, Action a = NORMAL);
53 protected:
54     struct link {
55         link *next;
56         link *prev;
57         link(link *n = 0, link *p = 0);
58         virtual ~link();
59     private:
60         link(const link&);
61         void operator=(const link&);
62     };
63     unsigned count;
64     link *list_head;             
65     link *list_tail;             
66     virtual link *copy_item(link *old_item) const = 0;
67     void prepend(link *item);
68     void append(link *item);
69     void prepend(const ListDProto& proto);
70     void append(const ListDProto& proto);
71     void remove(link *item);
72     link *ref(const Vix&) const;
74 template<class T>
75 class ListD: public ListDProto {
76 public:
77     void prepend(const T& item);
78     void append(const T& item);
79     const T& head() const;
80     T& head();
81     void head(T& fill) const;
82     void remove_head()
83         { ListDProto::remove_head(); }
84     void remove_head(T& fill);
85     const T& tail() const;
86     T& tail();
87     void tail(T& fill) const;
88     void remove_tail()
89         { ListDProto::remove_tail(); }
90     void remove_tail(T& fill);
91     class Vix: public ListDProto::Vix {
92     public:
93         Vix(): ListDProto::Vix()
94             { }
95     protected:
96         friend class ListD<T>;
97         Vix(const ListDProto::Vix& x): ListDProto::Vix(x)
98             { }
99     };
100     Vix first() const
101         { return ListDProto::first(); };
102     void first(Vix& x) const
103         { ListDProto::first(x); };
104     void next(Vix& x, ListDProto::Action a = NORMAL) const
105         { ListDProto::next(x, a); }// { dg-error "" } .*// ERROR - .*
106     Vix last() const
107         { return ListDProto::last(); }
108     void last(Vix& x) const
109         { return ListDProto::last(x); }
110     void prev(Vix& x, ListDProto::Action a = NORMAL) const
111         { return ListDProto::prev(x, a); }
112 protected:
113     struct link_item: public ListDProto::link {
114         T item;
115         link_item(const T& i): link(0, 0), item(i)
116             { }
117     private:
118         link_item(const link_item&);
119         void operator=(const link_item&);
120     };
121 public:
122     T& operator()(const Vix& x)
123         { link_item *li = (link_item *) ref(x);
124           return li->item; }
125     const T& operator()(const Vix& x) const
126         { link_item *li = (link_item *) ref(x);
127           return li->item; }
128 private:
129     ListDProto::link *copy_item(ListDProto::link *old_item) const;
131 template<class T>
132 class SetLD: private ListD<T> {
133 public:
134     SetLD();                     
135     SetLD(const ListD<T>&);      
136     void add(const T& item);
137     void add(const ListD<T>& other);
138     void add(const SetLD<T>& other);
139     void remove(const T& item);
140     bool contains(const T& item) const;
141     ListD<T>::length;
142     ListD<T>::empty;
143     ListD<T>::clear;
144     typedef typename ListD<T>::Vix Vix;
145     ListD<T>::first;
146     ListD<T>::next;
147     ListD<T>::operator();
149   using ListD<T>::NORMAL;
150   using ListD<T>::REMOVE_CURRENT;
152 extern "C" {
153 extern void __eprintf (const char *, const char *, unsigned, const char *);
155 extern "C" {
156 extern void __eprintf (const char *, const char *, unsigned, const char *);
158 template<class T>
159 void
160 ListD<T>::prepend(const T& item)
162     link *newl = new link_item(item);
163     ListDProto::prepend(newl);
165 template<class T>
166 void
167 ListD<T>::append(const T& item)
169     link *newl = new link_item(item); 
170     ListDProto::append(newl);
172 template<class T>
173 const T&
174 ListD<T>::head() const
176     ((void) (( 0 != list_head ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n",       "/home/wbaker/work/include/templates/ListD.body.h" ,   50 ,  "0 != list_head" ), 0) )) ;
177     link_item *h = (link_item *) list_head;
178     return h->item;
180 template<class T>
182 ListD<T>::head()
184     ((void) (( 0 != list_head ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n",       "/home/wbaker/work/include/templates/ListD.body.h" ,   59 ,  "0 != list_head" ), 0) )) ;
185     link_item *h = (link_item *) list_head;
186     return h->item;
188 template<class T>
189 void
190 ListD<T>::head(T& fill) const
192     ((void) (( 0 != list_head ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n",       "/home/wbaker/work/include/templates/ListD.body.h" ,   68 ,  "0 != list_head" ), 0) )) ;
193     link_item *h = (link_item *) list_head;
194     fill = h->item;
196 template<class T>
197 void
198 ListD<T>::remove_head(T& fill)
200     head(fill);
201     remove_head();
203 template<class T>
204 const T&
205 ListD<T>::tail() const
207     ((void) (( 0 != list_tail ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n",       "/home/wbaker/work/include/templates/ListD.body.h" ,   85 ,  "0 != list_tail" ), 0) )) ;
208     link_item *h = (link_item *) list_tail;
209     return h->item;
211 template<class T>
213 ListD<T>::tail()
215     ((void) (( 0 != list_tail ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n",       "/home/wbaker/work/include/templates/ListD.body.h" ,   94 ,  "0 != list_tail" ), 0) )) ;
216     link_item *h = (link_item *) list_tail;
217     return h->item;
219 template<class T>
220 void
221 ListD<T>::tail(T& fill) const
223     ((void) (( 0 != list_tail ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n",       "/home/wbaker/work/include/templates/ListD.body.h" ,   103 ,  "0 != list_tail" ), 0) )) ;
224     link_item *h = (link_item *) list_tail;
225     fill = h->item;
227 template<class T>
228 void
229 ListD<T>::remove_tail(T& fill)
231     ((void) (( 0 != list_tail ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n",       "/home/wbaker/work/include/templates/ListD.body.h" ,   112 ,  "0 != list_tail" ), 0) )) ;
232     link_item *h = (link_item *) list_tail;
233     fill = h->item;
235 template<class T>
236 ListDProto::link *
237 ListD<T>::copy_item(ListDProto::link *old) const
239     link_item *old_item = (link_item *) old;
240     link_item *new_item = new link_item(old_item->item);
241     return new_item;
243 template<class T>
244 SetLD<T>::SetLD():
245 ListD<T>()
246 { }
247 template<class T>
248 SetLD<T>::SetLD(const ListD<T>& other):
249 ListD<T>(other)
250 { }
251 template<class T>
252 void
253 SetLD<T>::add(const T& item)
255     if ( ! contains(item) )
256         append(item);
258 template<class T>
259 void
260 SetLD<T>::add(const ListD<T>& other)
262     typename ListD<T>::Vix x;
263     for (first(x); 0 != x; next(x))
264         add(other(x));
266 template<class T>
267 void
268 SetLD<T>::add(const SetLD<T>& other)
270     const ListD<T>& lother = other;
271     add(lother);
273 template<class T>
274 void
275 SetLD<T>::remove(const T& item)
277     typename ListD<T>::Action a = this->NORMAL;
278     Vix x;
279     for (first(x); 0 != x && this->REMOVE_CURRENT != a; next(x, a))
280         a = operator()(x) == item ? this->REMOVE_CURRENT: this->NORMAL; // { dg-error "" } .*
282 template<class T>
283 bool
284 SetLD<T>::contains(const T& item) const
286     Vix x;
287     for (first(x); 0 != x; next(x)) {
288         if (operator()(x) == item)// { dg-error "" } .*
289             return TRUE;
290     }
291     return FALSE;
293 template<class T>
295 operator==(const SetLD<T>& a, const SetLD<T>& b)
297     if (a.length() != b.length())
298         return FALSE;
299     typename SetLD<T>::Vix x;
300     for (a.first(x); 0 != x; a.next(x)) {
301         if ( ! b.contains(a(x)) )
302             return FALSE;
303     }
304     for (b.first(x); 0 != x; b.next(x)) {
305         if ( ! a.contains(b(x)) )
306             return FALSE;
307     }
308     return TRUE;
310 template<class T>
312 operator!=(const SetLD<T>& a, const SetLD<T>& b)
313 { return ! (a == b); }
314 template<class T>
316 operator<=(const SetLD<T>& a, const SetLD<T>& b)
318     if (a.length() > b.length())
319         return FALSE;
320     typename SetLD<T>::Vix x;
321     for (x=a.first(); 0 != x; a.next(x)) {
322         if ( ! b.contains(a(x)) )
323             return FALSE;
324     }
325     return TRUE;
327 template<class T>
329 operator<(const SetLD<T>& a, const SetLD<T>& b)
331     if (a.length() >= b.length())
332         return FALSE;
333     return a <= b;
335 template<class T>
337 operator>(const SetLD<T>& a, const SetLD<T>& b)
338 { return ! (a <= b); }
339 template<class T>
341 operator>=(const SetLD<T>& a, const SetLD<T>& b)
342 { return ! (a < b); }
343 class String { };
344 class IcaseString: public String { };
345 template <> class SetLD< IcaseString >: public SetLD<    String  > {    public:  SetLD (): SetLD<    String  >() { };    SetLD (const ListD<   IcaseString  >& other): SetLD<    String  >()    { ListD<   IcaseString  >::Vix x;       for (other.first(x); 0 != x; other.next(x))     add(other(x)); };        SetLD (const  SetLD & other): SetLD<    String  >(other) { };  const    IcaseString  & operator()(const Vix& x) const  { return (   IcaseString  &) SetLD<    String  >::operator()(x); }      };      typedef SetLD<  String > SetLD_String_IcaseString_old_tmp99;    typedef SetLD< IcaseString > SetLD_String_IcaseString_new_tmp99;        
346 inline int       operator== (const SetLD_String_IcaseString_new_tmp99& a,       const SetLD_String_IcaseString_new_tmp99& b) // { dg-error "operator==" }
348 const SetLD_String_IcaseString_old_tmp99& oa = a;
349 const SetLD_String_IcaseString_old_tmp99& ob = b;
350 return  operator== (oa, ob);    }       
351 inline int       operator!= (const SetLD_String_IcaseString_new_tmp99& a,       const SetLD_String_IcaseString_new_tmp99& b)
353 const SetLD_String_IcaseString_old_tmp99& oa = a;
354 const SetLD_String_IcaseString_old_tmp99& ob = b;
355 return  operator!= (oa, ob);    }       
356 inline int       operator< (const SetLD_String_IcaseString_new_tmp99& a,        const SetLD_String_IcaseString_new_tmp99& b)
358 const SetLD_String_IcaseString_old_tmp99& oa = a;
359 const SetLD_String_IcaseString_old_tmp99& ob = b;
360 return  operator< (oa, ob);     }       
361 inline int       operator<= (const SetLD_String_IcaseString_new_tmp99& a,       const SetLD_String_IcaseString_new_tmp99& b)
363 const SetLD_String_IcaseString_old_tmp99& oa = a;
364 const SetLD_String_IcaseString_old_tmp99& ob = b;
365 return  operator<= (oa, ob);    }       
366 inline int       operator> (const SetLD_String_IcaseString_new_tmp99& a,        const SetLD_String_IcaseString_new_tmp99& b)
368 const SetLD_String_IcaseString_old_tmp99& oa = a;
369 const SetLD_String_IcaseString_old_tmp99& ob = b;
370 return  operator> (oa, ob);     }       
371 inline int       operator>= (const SetLD_String_IcaseString_new_tmp99& a,       const SetLD_String_IcaseString_new_tmp99& b)
373 const SetLD_String_IcaseString_old_tmp99& oa = a;
374 const SetLD_String_IcaseString_old_tmp99& ob = b;
375 return  operator>= (oa, ob);    }   
376 typedef SetLD<IcaseString> SLDiS;
377 static void
378 nop(int i)
380     SetLD<IcaseString> x, y;
381     nop(x == y);
382  nop(x != y);
383 nop(x < y);
384 nop(x <= y);
385 nop(x > y);
386 nop(x >= y);
389 template class SetLD<String>;