1 // { dg-do assemble  }
2 // { dg-options "" }
3 // This test case caused the compiler to abort at one point in time.
4 // prms-id: 811
5 
6 class ostream; class streambuf;
7 
8 typedef long streamoff, streampos;
9 
10 struct _ios_fields {
11     streambuf *_strbuf;
12     ostream* _tie;
13     int _width;
14     unsigned long _flags;
15     char _fill;
16     unsigned char _state;
17     unsigned short _precision;
18 };
19 
20 
21 enum state_value { _good = 0, _eof = 1,  _fail = 2, _bad  = 4 };
22 enum open_mode { input=1, output=2, append=8 };
23 
24 
25 class ios : public _ios_fields {
26   public:
27     enum io_state { goodbit=0, eofbit=1, failbit=2, badbit=4 };
28     enum open_mode {
29 	in=1,
30 	out=2,
31 	ate=4,
32 	app=8,
33 	trunc=16,
34 	nocreate=32,
35 	noreplace=64 };
36     enum seek_dir { beg, cur, end};
37     enum { skipws=01, left=02, right=04, internal=010,
38 	   dec=020, oct=040, hex=0100,
39 	   showbase=0200, showpoint=0400, uppercase=01000, showpos=02000,
40 	   scientific=04000, fixed=0100000, unitbuf=020000, stdio=040000,
41 	   dont_close=0x80000000
42 	   };
43 
tie()44     ostream* tie() const { return _tie; }
tie(ostream * val)45     ostream* tie(ostream* val) { ostream* save=_tie; _tie=val; return save; }
46 
47 
fill()48     char fill() const { return _fill; }
fill(char newf)49     char fill(char newf) { char oldf = _fill; _fill = newf; return oldf; }
flags()50     unsigned long flags() const { return _flags; }
flags(unsigned long new_val)51     unsigned long flags(unsigned long new_val) {
52 	unsigned long old_val = _flags; _flags = new_val; return old_val; }
precision()53     unsigned short precision() const { return _precision; }
precision(int newp)54     unsigned short precision(int newp) {
55 	unsigned short oldp = _precision; _precision = (unsigned short)newp;
56 	return oldp; }
setf(unsigned long val)57     unsigned long setf(unsigned long val) {
58 	unsigned long oldbits = _flags;
59 	_flags |= val; return oldbits; }
setf(unsigned long val,unsigned long mask)60     unsigned long setf(unsigned long val, unsigned long mask) {
61 	unsigned long oldbits = _flags;
62 	_flags = (_flags & ~mask) | (val & mask); return oldbits; }
unsetf(unsigned long mask)63     unsigned long unsetf(unsigned long mask) {
64 	unsigned long oldbits = _flags & mask;
65 	_flags &= ~mask; return oldbits; }
width()66     int width() const { return _width; }
width(long val)67     int width(long val) { long save = _width; _width = val; return save; }
68 
69     static const unsigned long basefield;
70     static const unsigned long adjustfield;
71     static const unsigned long floatfield;
72 
rdbuf()73     streambuf* rdbuf() const { return _strbuf; }
74     void clear(int state = 0) { _state = state; }
good()75     int good() const { return _state == 0; }
eof()76     int eof() const { return _state & ios::eofbit; }
fail()77     int fail() const { return _state & (ios::badbit|ios::failbit); }
bad()78     int bad() const { return _state & ios::badbit; }
rdstate()79     int rdstate() const { return _state; }
set(int flag)80     void set(int flag) { _state |= flag; }
81     operator void*() const { return fail() ? (void*)0 : (void*)this; }
82     int operator!() const { return fail(); }
83 
84 
unset(state_value flag)85     void unset(state_value flag) { _state &= ~flag; }
86     void close();
87     int is_open();
88     int readable();
89     int writable();
90 
91 
92   protected:
ios(streambuf * sb)93     ios(streambuf*sb) { _strbuf=sb; _state=0; _width=0; _fill=' ';
94 			_flags=ios::skipws; _precision=6; }
95 };
96 
97 
98 
99 
100 typedef ios::seek_dir _seek_dir;
101 
102 
103 
104 
105 
106 
107 
108 
109 
110 
111 
112 
113 
114 
115 
116 
117 
118 
119 
120 
121 
122 
123 //# 168 "/usr/latest/lib/g++-include/streambuf.h" 3
124 
125 
126 struct __streambuf {
127 
128     int _flags;
129     char* _gptr;
130     char* _egptr;
131     char* _eback;
132     char* _pbase;
133     char* _pptr;
134     char* _epptr;
135     char* _base;
136     char* _ebuf;
137     struct streambuf *_chain;
138 
139 
140 
141 
142 };
143 
144 struct streambuf : private __streambuf {
145     friend class ios;
146     friend class istream;
147     friend class ostream;
148   protected:
149     static streambuf* _list_all;
xchainstreambuf150     streambuf*& xchain() { return _chain; }
151     void _un_link();
152     void _link_in();
gptrstreambuf153     char* gptr() const { return _gptr; }
pptrstreambuf154     char* pptr() const { return _pptr; }
egptrstreambuf155     char* egptr() const { return _egptr; }
epptrstreambuf156     char* epptr() const { return _epptr; }
pbasestreambuf157     char* pbase() const { return _pbase; }
ebackstreambuf158     char* eback() const { return _eback; }
ebufstreambuf159     char* ebuf() const { return _ebuf; }
basestreambuf160     char* base() const { return _base; }
xput_charstreambuf161     void xput_char(char c) { *_pptr++ = c; }
xflagsstreambuf162     int xflags() { return _flags; }
xflagsstreambuf163     int xflags(int f) { int fl = _flags; _flags = f; return fl; }
xsetflagsstreambuf164     void xsetflags(int f) { _flags |= f; }
gbumpstreambuf165     void gbump(int n) { _gptr += n; }
pbumpstreambuf166     void pbump(int n) { _pptr += n; }
167     void setb(char* b, char* eb, int a=0);
setpstreambuf168     void setp(char* p, char* ep) { _pbase=_pptr=p; _epptr=ep; }
setgstreambuf169     void setg(char* eb, char* g, char *eg) { _eback=eb; _gptr=g; _egptr=eg; }
170   public:
171     static int flush_all();
172     static void flush_all_linebuffered();
173     virtual int underflow();
174     virtual int overflow(int c = (-1) );
175     virtual int doallocate();
176     virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
177     virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out);
178     int sputbackc(char c);
179     int sungetc();
180     streambuf();
181     virtual ~streambuf();
unbufferedstreambuf182     int unbuffered() { return _flags & 2  ? 1 : 0; }
linebufferedstreambuf183     int linebuffered() { return _flags & 0x4000  ? 1 : 0; }
unbufferedstreambuf184     void unbuffered(int i)
185 	{ if (i) _flags |= 2 ; else _flags &= ~2 ; }
linebufferedstreambuf186     void linebuffered(int i)
187 	{ if (i) _flags |= 0x4000 ; else _flags &= ~0x4000 ; }
allocatestreambuf188     int allocate() {
189 	if (base() || unbuffered()) return 0;
190 	else return doallocate(); }
191     virtual int sync();
192     virtual int pbackfail(int c);
193     virtual int ungetfail();
194     virtual streambuf* setbuf(char* p, int len);
in_availstreambuf195     int in_avail() { return _egptr - _gptr; }
out_waitingstreambuf196     int out_waiting() { return _pptr - _pbase; }
197     virtual int sputn(const char* s, int n);
198     virtual int sgetn(char* s, int n);
199     long sgetline(char* buf, int  n, char delim, int putback_delim);
sbumpcstreambuf200     int sbumpc() {
201 	if (_gptr >= _egptr && underflow() == (-1) ) return (-1) ;
202 	else return *(unsigned char*)_gptr++; }
sgetcstreambuf203     int sgetc() {
204 	if (_gptr >= _egptr && underflow() == (-1) ) return (-1) ;
205 	else return *(unsigned char*)_gptr; }
snextcstreambuf206     int snextc() {
207 	if (++_gptr >= _egptr && underflow() == (-1) ) return (-1) ;
208 	else return *(unsigned char*)_gptr; }
sputcstreambuf209     int sputc(int c) {
210 	if (_pptr >= _epptr) return overflow(c);
211 	return *_pptr++ = c, (unsigned char)c; }
212     int vscan(char const *fmt0, char*  ap);
213     int vform(char const *fmt0, char*  ap);
214 
215 
216 
217 
218 
219 
220 };
221 
222 struct __file_fields {
223     char _fake;
224     char _shortbuf[1];
225     short _fileno;
226     int _blksize;
227     char* _save_gptr;
228     char* _save_egptr;
229     long   _offset;
230 };
231 
232 class filebuf : public streambuf {
233     struct __file_fields _fb;
234     void init();
235   public:
236     filebuf();
237     filebuf(int fd);
238     filebuf(int fd, char* p, int len);
239     ~filebuf();
240     filebuf* attach(int fd);
241     filebuf* open(const char *filename, const char *mode);
242     filebuf* open(const char *filename, int mode, int prot = 0664);
243     virtual int underflow();
244     virtual int overflow(int c = (-1) );
is_open()245     int is_open() { return _fb._fileno >= 0; }
fd()246     int fd() { return is_open() ? _fb._fileno : (-1) ; }
247     filebuf* close();
248     virtual int doallocate();
249     virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
250     int sputn(const char* s, int n);
251     int sgetn(char* s, int n);
252     virtual int sync();
253   protected:
254     virtual int pbackfail(int c);
is_reading()255     int is_reading() { return eback() != egptr(); }
cur_ptr()256     char* cur_ptr() { return is_reading() ?  gptr() : pptr(); }
257 
file_ptr()258     char* file_ptr() { return _fb._save_gptr ? _fb._save_egptr : egptr(); }
259     int do_flush();
260 
261     virtual int sys_read(char* buf, int  size);
262     virtual long   sys_seek(long  , _seek_dir);
263     virtual long sys_write(const void*, long);
264     virtual int sys_stat(void*);
265     virtual int sys_close();
266 };
267 
268 
readable()269 inline int ios::readable() { return rdbuf()->_flags & 4 ; }
writable()270 inline int ios::writable() { return rdbuf()->_flags & 8 ; }
is_open()271 inline int ios::is_open() {return rdbuf()->_flags & 4 +8 ;}
272 
273 
274 
275 
276 //# 25 "/usr/latest/lib/g++-include/iostream.h" 2 3
277 
278 
279 class istream; class ostream;
280 typedef istream& (*__imanip)(istream&);
281 typedef ostream& (*__omanip)(ostream&);
282 
283 extern istream& ws(istream& ins);
284 extern ostream& flush(ostream& outs);
285 extern ostream& endl(ostream& outs);
286 extern ostream& ends(ostream& outs);
287 
288 class ostream : public ios
289 {
290     void do_osfx();
291   public:
292     ostream();
293     ostream(streambuf* sb, ostream* tied=__null );
294     ~ostream();
295 
opfx()296     int opfx() { if (!good()) return 0; if (_tie) _tie->flush(); return 1; }
osfx()297     void osfx() { if (flags() & (ios::unitbuf|ios::stdio))
298 		      do_osfx(); }
ostreambuf()299     streambuf* ostreambuf() const { return _strbuf; }
300     ostream& flush();
301     ostream& put(char c);
302     ostream& write(const char *s, int n);
write(const unsigned char * s,int n)303     ostream& write(const unsigned char *s, int n) { return write((char*)s, n);}
write(const void * s,int n)304     ostream& write(const void *s, int n) { return write((char*)s, n);}
305     ostream& seekp(streampos);
306     ostream& seekp(streamoff, _seek_dir);
307     streampos tellp();
308     ostream& form(const char *format ...);
309     ostream& vform(const char *format, char*  args);
310 };
311 
312 extern ostream& operator<<(ostream&, char c);
313 inline ostream& operator<<(ostream& os, unsigned char c)
314 { return os << (char)c; }
315 
316 extern ostream& operator<<(ostream&, const char *s);
317 inline ostream& operator<<(ostream& os, const unsigned char *s)
318 { return os << (const char*)s; }
319 
320 
321 extern ostream& operator<<(ostream&, void *p);
322 extern ostream& operator<<(ostream&, int n);
323 extern ostream& operator<<(ostream&, long n);
324 extern ostream& operator<<(ostream&, unsigned int n);
325 extern ostream& operator<<(ostream&, unsigned long n);
326 inline ostream& operator<<(ostream& os, short n) {return os << (int)n;}
327 inline ostream& operator<<(ostream& os, unsigned short n)
328 {return os << (unsigned int)n;}
329 extern ostream& operator<<(ostream&, float n);
330 extern ostream& operator<<(ostream&, double n);
331 inline ostream& operator<<(ostream& os, __omanip func) { return (*func)(os); }
332 extern ostream& operator<<(ostream&, streambuf*);
333 
334 class istream : public ios
335 {
336     int  _gcount;
337   public:
338     istream();
339     istream(streambuf* sb, ostream*tied=__null );
340     ~istream();
istreambuf()341     streambuf* istreambuf() const { return _strbuf; }
342     istream& get(char& c);
343     istream& get(unsigned char& c);
344     istream& read(char *ptr, int n);
read(unsigned char * ptr,int n)345     istream& read(unsigned char *ptr, int n) { return read((char*)ptr, n); }
read(void * ptr,int n)346     istream& read(void *ptr, int n) { return read((char*)ptr, n); }
347 
348     istream& getline(char* ptr, int len, char delim = '\n');
349     istream& get(char* ptr, int len, char delim = '\n');
350     istream& gets(char **s, char delim = '\n');
ipfx(int need)351     int ipfx(int need) {
352 	if (!good()) { set(ios::failbit); return 0; }
353 	if (_tie && (need == 0 || rdbuf()->in_avail() < need)) _tie->flush();
354 	if (!need && (flags() & ios::skipws) && !ws(*this)) return 0;
355 	return 1;
356     }
ipfx0()357     int ipfx0() {
358 	if (!good()) { set(ios::failbit); return 0; }
359 	if (_tie) _tie->flush();
360 	if ((flags() & ios::skipws) && !ws(*this)) return 0;
361 	return 1;
362     }
ipfx1()363     int ipfx1() {
364 	if (!good()) { set(ios::failbit); return 0; }
365 	if (_tie && rdbuf()->in_avail() == 0) _tie->flush();
366 	return 1;
367     }
get()368     int get() { if (!ipfx1()) return (-1) ;
369 		int ch = _strbuf->sbumpc();
370 		if (ch == (-1) ) set(ios::eofbit);
371 		return ch; }
peek()372     int peek() { if (!ipfx1()) return (-1) ;
373 		int ch = _strbuf->sgetc();
374 		if (ch == (-1) ) set(ios::eofbit);
375 		return ch; }
gcount()376     int  gcount() { return _gcount; }
377     istream& ignore(int n=1, int delim = (-1) );
378     istream& seekg(streampos);
379     istream& seekg(streamoff, _seek_dir);
380     streampos tellg();
putback(char ch)381     istream& putback(char ch) {
382 	if (good() && _strbuf->sputbackc(ch) == (-1) ) clear(ios::badbit);
383 	return *this;}
unget()384     istream& unget() {
385 	if (good() && _strbuf->sungetc() == (-1) ) clear(ios::badbit);
386 	return *this;}
387 
unget(char ch)388     istream& unget(char ch) { return putback(ch); }
389     int skip(int i);
390 
391 };
392 
393 extern istream& operator>>(istream&, char*);
394 inline istream& operator>>(istream& is, unsigned char* p)
395 { return is >> (char*)p; }
396 
397 extern istream& operator>>(istream&, char& c);
398 extern istream& operator>>(istream&, unsigned char& c);
399 
400 extern istream& operator>>(istream&, int&);
401 extern istream& operator>>(istream&, long&);
402 extern istream& operator>>(istream&, short&);
403 extern istream& operator>>(istream&, unsigned int&);
404 extern istream& operator>>(istream&, unsigned long&);
405 extern istream& operator>>(istream&, unsigned short&);
406 extern istream& operator>>(istream&, float&);
407 extern istream& operator>>(istream&, double&);
408 inline istream& operator>>(istream& is, __imanip func) { return (*func)(is); }
409 
put(char c)410 inline ostream& ostream::put(char c) { _strbuf->sputc(c); return *this; }
411 
412 class iostream : public ios {
413     int  _gcount;
414   public:
415     iostream();
416     iostream(streambuf* sb, ostream*tied=__null );
417     operator istream&() { return *(istream*)this; }
418     operator ostream&() { return *(ostream*)this; }
419     ~iostream();
420 
get(char & c)421     istream& get(char& c) { return ((istream*)this)->get(c); }
get(unsigned char & c)422     istream& get(unsigned char& c) { return ((istream*)this)->get(c); }
read(char * ptr,int n)423     istream& read(char *ptr, int n) { return ((istream*)this)->read(ptr, n); }
read(unsigned char * ptr,int n)424     istream& read(unsigned char *ptr, int n)
425 	{ return ((istream*)this)->read((char*)ptr, n); }
read(void * ptr,int n)426     istream& read(void *ptr, int n)
427 	{ return ((istream*)this)->read((char*)ptr, n); }
428     istream& getline(char* ptr, int len, char delim = '\n')
429 	{ return ((istream*)this)->getline(ptr, len, delim); }
430     istream& get(char* ptr, int len, char delim = '\n')
431 	{ return ((istream*)this)->get(ptr, len, delim); }
432     istream& gets(char **s, char delim = '\n')
433 	{ return ((istream*)this)->gets(s, delim); }
434     istream& ignore(int n=1, int delim = (-1) )
435 	{ return ((istream*)this)->ignore(n, delim); }
ipfx(int need)436     int ipfx(int need) { return ((istream*)this)->ipfx(need); }
ipfx0()437     int ipfx0()  { return ((istream*)this)->ipfx0(); }
ipfx1()438     int ipfx1()  { return ((istream*)this)->ipfx1(); }
get()439     int get() { return _strbuf->sbumpc(); }
peek()440     int peek() { return ipfx1() ? _strbuf->sgetc() : (-1) ; }
gcount()441     int  gcount() { return _gcount; }
putback(char ch)442     istream& putback(char ch) { return ((istream*)this)->putback(ch); }
unget()443     istream& unget() { return ((istream*)this)->unget(); }
seekg(streampos pos)444     istream& seekg(streampos pos) { return ((istream*)this)->seekg(pos); }
seekg(streamoff off,_seek_dir dir)445     istream& seekg(streamoff off, _seek_dir dir)
446 	{ return ((istream*)this)->seekg(off, dir); }
tellg()447     streampos tellg() { return ((istream*)this)->tellg(); }
448 
unget(char ch)449     istream& unget(char ch) { return putback(ch); }
450 
451 
452 
opfx()453     int opfx() { return ((ostream*)this)->opfx(); }
osfx()454     void osfx() { ((ostream*)this)->osfx(); }
flush()455     ostream& flush() { return ((ostream*)this)->flush(); }
put(char c)456     ostream& put(char c) { return ((ostream*)this)->put(c); }
write(const char * s,int n)457     ostream& write(const char *s, int n)
458 	{ return ((ostream*)this)->write(s, n); }
write(const unsigned char * s,int n)459     ostream& write(const unsigned char *s, int n)
460 	{ return ((ostream*)this)->write((char*)s, n); }
write(const void * s,int n)461     ostream& write(const void *s, int n)
462 	{ return ((ostream*)this)->write((char*)s, n); }
463     ostream& form(const char *format ...);
vform(const char * format,char * args)464     ostream& vform(const char *format, char*  args)
465 	{ return ((ostream*)this)->vform(format, args); }
seekp(streampos pos)466     ostream& seekp(streampos pos) { return ((ostream*)this)->seekp(pos); }
seekp(streamoff off,_seek_dir dir)467     ostream& seekp(streamoff off, _seek_dir dir)
468 	{ return ((ostream*)this)->seekp(off, dir); }
tellp()469     streampos tellp() { return ((ostream*)this)->tellp(); }
470 };
471 
472 extern istream cin;
473 extern ostream cout, cerr, clog;
474 
475 struct Iostream_init { } ;
476 
dec(ios & i)477 inline ios& dec(ios& i)
478 { i.setf(ios::dec, ios::dec|ios::hex|ios::oct); return i; }
hex(ios & i)479 inline ios& hex(ios& i)
480 { i.setf(ios::hex, ios::dec|ios::hex|ios::oct); return i; }
oct(ios & i)481 inline ios& oct(ios& i)
482 { i.setf(ios::oct, ios::dec|ios::hex|ios::oct); return i; }
483 
484 
485 //# 7 "/usr/latest/lib/g++-include/stream.h" 2 3
486 
487 
488 extern char* form(const char*, ...);
489 
490 extern char* dec(long, int=0);
491 extern char* dec(int, int=0);
492 extern char* dec(unsigned long, int=0);
493 extern char* dec(unsigned int, int=0);
494 
495 extern char* hex(long, int=0);
496 extern char* hex(int, int=0);
497 extern char* hex(unsigned long, int=0);
498 extern char* hex(unsigned int, int=0);
499 
500 extern char* oct(long, int=0);
501 extern char* oct(int, int=0);
502 extern char* oct(unsigned long, int=0);
503 extern char* oct(unsigned int, int=0);
504 
WS(istream & str)505 inline istream& WS(istream& str) { return ws(str); }
506 
507 
508 //# 9 "test.C" 2
509 
510 
511 class Y {
512 public:
Y()513     Y() {}
514   virtual const char *stringify() = 0;
515     virtual char *stringify2() const = 0; // { dg-error "overriding" }
516 };
517 
518 class X: public Y {
519 public:
X()520     X(): Y() {}
521     const char *stringify();		// { dg-error "candidate" }
522     const char *stringify2() const;  // { dg-error "candidate|conflicting return type" }
523 };
524 
525 char *
stringify()526 X::stringify() const  // { dg-error "does not match" }
527 {
528     return "stringify";
529 }
530 
531 const char *
stringify2()532 X::stringify2()   // { dg-error "does not match" }
533 {
534     return "stringify2";
535 }
536 
main()537 main()
538 {
539     X x;
540     Y& y = x;
541 
542     cout << "x\n";
543     cout << x.stringify() << '\n';
544     cout << x.stringify2() << '\n';
545 
546     cout << "y\n";
547     cout << y.stringify() << '\n';
548     cout << y.stringify2() << '\n';
549 }
550