Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.brendan/crash56.C

raw
1 // { dg-do assemble }
2 // { dg-options "-Wno-deprecated" }
3 // GROUPS passed old-abort
4
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)
24 { return v == x.item; }
25 friend int operator==(const Vix& x, void *v)
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)
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;
73 };
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;
130 };
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();
148
149 using ListD<T>::NORMAL;
150 using ListD<T>::REMOVE_CURRENT;
151 };
152 extern "C" {
153 extern void __eprintf (const char *, const char *, unsigned, const char *);
154 }
155 extern "C" {
156 extern void __eprintf (const char *, const char *, unsigned, const char *);
157 }
158 template<class T>
159 void
160 ListD<T>::prepend(const T& item)
161 {
162 link *newl = new link_item(item);
163 ListDProto::prepend(newl);
164 }
165 template<class T>
166 void
167 ListD<T>::append(const T& item)
168 {
169 link *newl = new link_item(item);
170 ListDProto::append(newl);
171 }
172 template<class T>
173 const T&
174 ListD<T>::head() const
175 {
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;
179 }
180 template<class T>
181 T&
182 ListD<T>::head()
183 {
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;
187 }
188 template<class T>
189 void
190 ListD<T>::head(T& fill) const
191 {
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;
195 }
196 template<class T>
197 void
198 ListD<T>::remove_head(T& fill)
199 {
200 head(fill);
201 remove_head();
202 }
203 template<class T>
204 const T&
205 ListD<T>::tail() const
206 {
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;
210 }
211 template<class T>
212 T&
213 ListD<T>::tail()
214 {
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;
218 }
219 template<class T>
220 void
221 ListD<T>::tail(T& fill) const
222 {
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;
226 }
227 template<class T>
228 void
229 ListD<T>::remove_tail(T& fill)
230 {
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;
234 }
235 template<class T>
236 ListDProto::link *
237 ListD<T>::copy_item(ListDProto::link *old) const
238 {
239 link_item *old_item = (link_item *) old;
240 link_item *new_item = new link_item(old_item->item);
241 return new_item;
242 }
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)
254 {
255 if ( ! contains(item) )
256 this->append(item);
257 }
258 template<class T>
259 void
260 SetLD<T>::add(const ListD<T>& other)
261 {
262 typename ListD<T>::Vix x;
263 for (first(x); 0 != x; next(x))
264 add(other(x));
265 }
266 template<class T>
267 void
268 SetLD<T>::add(const SetLD<T>& other)
269 {
270 const ListD<T>& lother = other;
271 add(lother);
272 }
273 template<class T>
274 void
275 SetLD<T>::remove(const T& item)
276 {
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 "" } .*
281 // { dg-message "(candidate|not derived from)" "candidate note" { target *-*-* } .-1 }
282 }
283 template<class T>
284 bool
285 SetLD<T>::contains(const T& item) const
286 {
287 Vix x;
288 for (first(x); 0 != x; next(x)) {
289 if (operator()(x) == item)// { dg-error "" } .*
290 // { dg-message "(candidate|not derived from)" "candidate note" { target *-*-* } .-1 }
291 return TRUE;
292 }
293 return FALSE;
294 }
295 template<class T>
296 int
297 operator==(const SetLD<T>& a, const SetLD<T>& b) // { dg-message "note" }
298 {
299 if (a.length() != b.length())
300 return FALSE;
301 typename SetLD<T>::Vix x;
302 for (a.first(x); 0 != x; a.next(x)) {
303 if ( ! b.contains(a(x)) )
304 return FALSE;
305 }
306 for (b.first(x); 0 != x; b.next(x)) {
307 if ( ! a.contains(b(x)) )
308 return FALSE;
309 }
310 return TRUE;
311 }
312 template<class T>
313 int
314 operator!=(const SetLD<T>& a, const SetLD<T>& b)
315 { return ! (a == b); }
316 template<class T>
317 int
318 operator<=(const SetLD<T>& a, const SetLD<T>& b)
319 {
320 if (a.length() > b.length())
321 return FALSE;
322 typename SetLD<T>::Vix x;
323 for (x=a.first(); 0 != x; a.next(x)) {
324 if ( ! b.contains(a(x)) )
325 return FALSE;
326 }
327 return TRUE;
328 }
329 template<class T>
330 int
331 operator<(const SetLD<T>& a, const SetLD<T>& b)
332 {
333 if (a.length() >= b.length())
334 return FALSE;
335 return a <= b;
336 }
337 template<class T>
338 int
339 operator>(const SetLD<T>& a, const SetLD<T>& b)
340 { return ! (a <= b); }
341 template<class T>
342 int
343 operator>=(const SetLD<T>& a, const SetLD<T>& b)
344 { return ! (a < b); }
345 class String { };
346 class IcaseString: public String { };
347 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;
348 inline int operator== (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b) // { dg-message "operator==|no known conversion" }
349 {
350 const SetLD_String_IcaseString_old_tmp99& oa = a;
351 const SetLD_String_IcaseString_old_tmp99& ob = b;
352 return operator== (oa, ob); }
353 inline int operator!= (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b)
354 {
355 const SetLD_String_IcaseString_old_tmp99& oa = a;
356 const SetLD_String_IcaseString_old_tmp99& ob = b;
357 return operator!= (oa, ob); }
358 inline int operator< (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b)
359 {
360 const SetLD_String_IcaseString_old_tmp99& oa = a;
361 const SetLD_String_IcaseString_old_tmp99& ob = b;
362 return operator< (oa, ob); }
363 inline int operator<= (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b)
364 {
365 const SetLD_String_IcaseString_old_tmp99& oa = a;
366 const SetLD_String_IcaseString_old_tmp99& ob = b;
367 return operator<= (oa, ob); }
368 inline int operator> (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b)
369 {
370 const SetLD_String_IcaseString_old_tmp99& oa = a;
371 const SetLD_String_IcaseString_old_tmp99& ob = b;
372 return operator> (oa, ob); }
373 inline int operator>= (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b)
374 {
375 const SetLD_String_IcaseString_old_tmp99& oa = a;
376 const SetLD_String_IcaseString_old_tmp99& ob = b;
377 return operator>= (oa, ob); }
378 typedef SetLD<IcaseString> SLDiS;
379 static void
380 nop(int i)
381 {
382 SetLD<IcaseString> x, y;
383 nop(x == y);
384 nop(x != y);
385 nop(x < y);
386 nop(x <= y);
387 nop(x > y);
388 nop(x >= y);
389 }
390
391 template class SetLD<String>;