11556Srgrimes// { dg-do assemble } 21556Srgrimes// { dg-options "" } 31556Srgrimes// This test case caused the compiler to abort at one point in time. 41556Srgrimes// prms-id: 811 51556Srgrimes 61556Srgrimesclass ostream; class streambuf; 71556Srgrimes 81556Srgrimestypedef long streamoff, streampos; 91556Srgrimes 101556Srgrimesstruct _ios_fields { 111556Srgrimes streambuf *_strbuf; 121556Srgrimes ostream* _tie; 131556Srgrimes int _width; 141556Srgrimes unsigned long _flags; 151556Srgrimes char _fill; 161556Srgrimes unsigned char _state; 171556Srgrimes unsigned short _precision; 181556Srgrimes}; 191556Srgrimes 201556Srgrimes 211556Srgrimesenum state_value { _good = 0, _eof = 1, _fail = 2, _bad = 4 }; 221556Srgrimesenum open_mode { input=1, output=2, append=8 }; 231556Srgrimes 241556Srgrimes 251556Srgrimesclass ios : public _ios_fields { 261556Srgrimes public: 271556Srgrimes enum io_state { goodbit=0, eofbit=1, failbit=2, badbit=4 }; 281556Srgrimes enum open_mode { 291556Srgrimes in=1, 301556Srgrimes out=2, 311556Srgrimes ate=4, 321556Srgrimes app=8, 331556Srgrimes trunc=16, 341556Srgrimes nocreate=32, 3520424Ssteve noreplace=64 }; 361556Srgrimes enum seek_dir { beg, cur, end}; 371556Srgrimes enum { skipws=01, left=02, right=04, internal=010, 381556Srgrimes dec=020, oct=040, hex=0100, 391556Srgrimes showbase=0200, showpoint=0400, uppercase=01000, showpos=02000, 401556Srgrimes scientific=04000, fixed=0100000, unitbuf=020000, stdio=040000, 4136152Scharnier dont_close=0x80000000 4236152Scharnier }; 4336152Scharnier 4436152Scharnier ostream* tie() const { return _tie; } 4550471Speter ostream* tie(ostream* val) { ostream* save=_tie; _tie=val; return save; } 461556Srgrimes 471556Srgrimes 481556Srgrimes char fill() const { return _fill; } 491556Srgrimes char fill(char newf) { char oldf = _fill; _fill = newf; return oldf; } 501556Srgrimes unsigned long flags() const { return _flags; } 511556Srgrimes unsigned long flags(unsigned long new_val) { 521556Srgrimes unsigned long old_val = _flags; _flags = new_val; return old_val; } 531556Srgrimes unsigned short precision() const { return _precision; } 541556Srgrimes unsigned short precision(int newp) { 551556Srgrimes unsigned short oldp = _precision; _precision = (unsigned short)newp; 561556Srgrimes return oldp; } 571556Srgrimes unsigned long setf(unsigned long val) { 581556Srgrimes unsigned long oldbits = _flags; 591556Srgrimes _flags |= val; return oldbits; } 601556Srgrimes unsigned long setf(unsigned long val, unsigned long mask) { 611556Srgrimes unsigned long oldbits = _flags; 6276810Skris _flags = (_flags & ~mask) | (val & mask); return oldbits; } 6376810Skris unsigned long unsetf(unsigned long mask) { 641556Srgrimes unsigned long oldbits = _flags & mask; 658855Srgrimes _flags &= ~mask; return oldbits; } 661556Srgrimes int width() const { return _width; } 671556Srgrimes int width(long val) { long save = _width; _width = val; return save; } 681556Srgrimes 691556Srgrimes static const unsigned long basefield; 701556Srgrimes static const unsigned long adjustfield; 711556Srgrimes static const unsigned long floatfield; 721556Srgrimes 731556Srgrimes streambuf* rdbuf() const { return _strbuf; } 741556Srgrimes void clear(int state = 0) { _state = state; } 751556Srgrimes int good() const { return _state == 0; } 761556Srgrimes int eof() const { return _state & ios::eofbit; } 771556Srgrimes int fail() const { return _state & (ios::badbit|ios::failbit); } 781556Srgrimes int bad() const { return _state & ios::badbit; } 7924348Simp int rdstate() const { return _state; } 801556Srgrimes void set(int flag) { _state |= flag; } 811556Srgrimes operator void*() const { return fail() ? (void*)0 : (void*)this; } 821556Srgrimes int operator!() const { return fail(); } 831556Srgrimes 841556Srgrimes 851556Srgrimes void unset(state_value flag) { _state &= ~flag; } 861556Srgrimes void close(); 871556Srgrimes int is_open(); 881556Srgrimes int readable(); 891556Srgrimes int writable(); 901556Srgrimes 911556Srgrimes 921556Srgrimes protected: 931556Srgrimes ios(streambuf*sb) { _strbuf=sb; _state=0; _width=0; _fill=' '; 941556Srgrimes _flags=ios::skipws; _precision=6; } 951556Srgrimes}; 961556Srgrimes 971556Srgrimes 981556Srgrimes 991556Srgrimes 1001556Srgrimestypedef ios::seek_dir _seek_dir; 1011556Srgrimes 1029393Sbde 1039393Sbde 1041556Srgrimes 1051556Srgrimes 1061556Srgrimes 10759790Sache 1081556Srgrimes 1091556Srgrimes 1101556Srgrimes 1111556Srgrimes 1121556Srgrimes 1131556Srgrimes 1141556Srgrimes 1151556Srgrimes 1161556Srgrimes 1171556Srgrimes 11859788Sache 1191556Srgrimes 1201556Srgrimes 12159788Sache 1221556Srgrimes 1231556Srgrimes//# 168 "/usr/latest/lib/g++-include/streambuf.h" 3 1248855Srgrimes 12559788Sache 1261556Srgrimesstruct __streambuf { 1271556Srgrimes 1281556Srgrimes int _flags; 1291556Srgrimes char* _gptr; 1301556Srgrimes char* _egptr; 1311556Srgrimes char* _eback; 1321556Srgrimes char* _pbase; 1331556Srgrimes char* _pptr; 1341556Srgrimes char* _epptr; 1351556Srgrimes char* _base; 13676810Skris char* _ebuf; 1371556Srgrimes struct streambuf *_chain; 1381556Srgrimes 1391556Srgrimes 1401556Srgrimes 1411556Srgrimes 1421556Srgrimes}; 1431556Srgrimes 1441556Srgrimesstruct streambuf : private __streambuf { 1451556Srgrimes friend class ios; 14659788Sache friend class istream; 14759788Sache friend class ostream; 1481556Srgrimes protected: 1491556Srgrimes static streambuf* _list_all; 1501556Srgrimes streambuf*& xchain() { return _chain; } 1511556Srgrimes void _un_link(); 1521556Srgrimes void _link_in(); 1531556Srgrimes char* gptr() const { return _gptr; } 1541556Srgrimes char* pptr() const { return _pptr; } 1551556Srgrimes char* egptr() const { return _egptr; } 1561556Srgrimes char* epptr() const { return _epptr; } 1571556Srgrimes char* pbase() const { return _pbase; } 1581556Srgrimes char* eback() const { return _eback; } 1591556Srgrimes char* ebuf() const { return _ebuf; } 1601556Srgrimes char* base() const { return _base; } 1611556Srgrimes void xput_char(char c) { *_pptr++ = c; } 1621556Srgrimes int xflags() { return _flags; } 1631556Srgrimes int xflags(int f) { int fl = _flags; _flags = f; return fl; } 1641556Srgrimes void xsetflags(int f) { _flags |= f; } 1651556Srgrimes void gbump(int n) { _gptr += n; } 16626468Scharnier void pbump(int n) { _pptr += n; } 1671556Srgrimes void setb(char* b, char* eb, int a=0); 1681556Srgrimes void setp(char* p, char* ep) { _pbase=_pptr=p; _epptr=ep; } 169 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(); 182 int unbuffered() { return _flags & 2 ? 1 : 0; } 183 int linebuffered() { return _flags & 0x4000 ? 1 : 0; } 184 void unbuffered(int i) 185 { if (i) _flags |= 2 ; else _flags &= ~2 ; } 186 void linebuffered(int i) 187 { if (i) _flags |= 0x4000 ; else _flags &= ~0x4000 ; } 188 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); 195 int in_avail() { return _egptr - _gptr; } 196 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); 200 int sbumpc() { 201 if (_gptr >= _egptr && underflow() == (-1) ) return (-1) ; 202 else return *(unsigned char*)_gptr++; } 203 int sgetc() { 204 if (_gptr >= _egptr && underflow() == (-1) ) return (-1) ; 205 else return *(unsigned char*)_gptr; } 206 int snextc() { 207 if (++_gptr >= _egptr && underflow() == (-1) ) return (-1) ; 208 else return *(unsigned char*)_gptr; } 209 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 222struct __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 232class 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) ); 245 int is_open() { return _fb._fileno >= 0; } 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); 255 int is_reading() { return eback() != egptr(); } 256 char* cur_ptr() { return is_reading() ? gptr() : pptr(); } 257 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 269inline int ios::readable() { return rdbuf()->_flags & 4 ; } 270inline int ios::writable() { return rdbuf()->_flags & 8 ; } 271inline 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 279class istream; class ostream; 280typedef istream& (*__imanip)(istream&); 281typedef ostream& (*__omanip)(ostream&); 282 283extern istream& ws(istream& ins); 284extern ostream& flush(ostream& outs); 285extern ostream& endl(ostream& outs); 286extern ostream& ends(ostream& outs); 287 288class ostream : public ios 289{ 290 void do_osfx(); 291 public: 292 ostream(); 293 ostream(streambuf* sb, ostream* tied=__null ); 294 ~ostream(); 295 296 int opfx() { if (!good()) return 0; if (_tie) _tie->flush(); return 1; } 297 void osfx() { if (flags() & (ios::unitbuf|ios::stdio)) 298 do_osfx(); } 299 streambuf* ostreambuf() const { return _strbuf; } 300 ostream& flush(); 301 ostream& put(char c); 302 ostream& write(const char *s, int n); 303 ostream& write(const unsigned char *s, int n) { return write((char*)s, 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 312extern ostream& operator<<(ostream&, char c); 313inline ostream& operator<<(ostream& os, unsigned char c) 314{ return os << (char)c; } 315 316extern ostream& operator<<(ostream&, const char *s); 317inline ostream& operator<<(ostream& os, const unsigned char *s) 318{ return os << (const char*)s; } 319 320 321extern ostream& operator<<(ostream&, void *p); 322extern ostream& operator<<(ostream&, int n); 323extern ostream& operator<<(ostream&, long n); 324extern ostream& operator<<(ostream&, unsigned int n); 325extern ostream& operator<<(ostream&, unsigned long n); 326inline ostream& operator<<(ostream& os, short n) {return os << (int)n;} 327inline ostream& operator<<(ostream& os, unsigned short n) 328{return os << (unsigned int)n;} 329extern ostream& operator<<(ostream&, float n); 330extern ostream& operator<<(ostream&, double n); 331inline ostream& operator<<(ostream& os, __omanip func) { return (*func)(os); } 332extern ostream& operator<<(ostream&, streambuf*); 333 334class istream : public ios 335{ 336 int _gcount; 337 public: 338 istream(); 339 istream(streambuf* sb, ostream*tied=__null ); 340 ~istream(); 341 streambuf* istreambuf() const { return _strbuf; } 342 istream& get(char& c); 343 istream& get(unsigned char& c); 344 istream& read(char *ptr, int n); 345 istream& read(unsigned char *ptr, int n) { return read((char*)ptr, 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'); 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 } 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 } 363 int ipfx1() { 364 if (!good()) { set(ios::failbit); return 0; } 365 if (_tie && rdbuf()->in_avail() == 0) _tie->flush(); 366 return 1; 367 } 368 int get() { if (!ipfx1()) return (-1) ; 369 int ch = _strbuf->sbumpc(); 370 if (ch == (-1) ) set(ios::eofbit); 371 return ch; } 372 int peek() { if (!ipfx1()) return (-1) ; 373 int ch = _strbuf->sgetc(); 374 if (ch == (-1) ) set(ios::eofbit); 375 return ch; } 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(); 381 istream& putback(char ch) { 382 if (good() && _strbuf->sputbackc(ch) == (-1) ) clear(ios::badbit); 383 return *this;} 384 istream& unget() { 385 if (good() && _strbuf->sungetc() == (-1) ) clear(ios::badbit); 386 return *this;} 387 388 istream& unget(char ch) { return putback(ch); } 389 int skip(int i); 390 391}; 392 393extern istream& operator>>(istream&, char*); 394inline istream& operator>>(istream& is, unsigned char* p) 395{ return is >> (char*)p; } 396 397extern istream& operator>>(istream&, char& c); 398extern istream& operator>>(istream&, unsigned char& c); 399 400extern istream& operator>>(istream&, int&); 401extern istream& operator>>(istream&, long&); 402extern istream& operator>>(istream&, short&); 403extern istream& operator>>(istream&, unsigned int&); 404extern istream& operator>>(istream&, unsigned long&); 405extern istream& operator>>(istream&, unsigned short&); 406extern istream& operator>>(istream&, float&); 407extern istream& operator>>(istream&, double&); 408inline istream& operator>>(istream& is, __imanip func) { return (*func)(is); } 409 410inline ostream& ostream::put(char c) { _strbuf->sputc(c); return *this; } 411 412class 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 421 istream& get(char& c) { return ((istream*)this)->get(c); } 422 istream& get(unsigned char& c) { return ((istream*)this)->get(c); } 423 istream& read(char *ptr, int n) { return ((istream*)this)->read(ptr, n); } 424 istream& read(unsigned char *ptr, int n) 425 { return ((istream*)this)->read((char*)ptr, 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); } 436 int ipfx(int need) { return ((istream*)this)->ipfx(need); } 437 int ipfx0() { return ((istream*)this)->ipfx0(); } 438 int ipfx1() { return ((istream*)this)->ipfx1(); } 439 int get() { return _strbuf->sbumpc(); } 440 int peek() { return ipfx1() ? _strbuf->sgetc() : (-1) ; } 441 int gcount() { return _gcount; } 442 istream& putback(char ch) { return ((istream*)this)->putback(ch); } 443 istream& unget() { return ((istream*)this)->unget(); } 444 istream& seekg(streampos pos) { return ((istream*)this)->seekg(pos); } 445 istream& seekg(streamoff off, _seek_dir dir) 446 { return ((istream*)this)->seekg(off, dir); } 447 streampos tellg() { return ((istream*)this)->tellg(); } 448 449 istream& unget(char ch) { return putback(ch); } 450 451 452 453 int opfx() { return ((ostream*)this)->opfx(); } 454 void osfx() { ((ostream*)this)->osfx(); } 455 ostream& flush() { return ((ostream*)this)->flush(); } 456 ostream& put(char c) { return ((ostream*)this)->put(c); } 457 ostream& write(const char *s, int n) 458 { return ((ostream*)this)->write(s, n); } 459 ostream& write(const unsigned char *s, int n) 460 { return ((ostream*)this)->write((char*)s, n); } 461 ostream& write(const void *s, int n) 462 { return ((ostream*)this)->write((char*)s, n); } 463 ostream& form(const char *format ...); 464 ostream& vform(const char *format, char* args) 465 { return ((ostream*)this)->vform(format, args); } 466 ostream& seekp(streampos pos) { return ((ostream*)this)->seekp(pos); } 467 ostream& seekp(streamoff off, _seek_dir dir) 468 { return ((ostream*)this)->seekp(off, dir); } 469 streampos tellp() { return ((ostream*)this)->tellp(); } 470}; 471 472extern istream cin; 473extern ostream cout, cerr, clog; 474 475struct Iostream_init { } ; 476 477inline ios& dec(ios& i) 478{ i.setf(ios::dec, ios::dec|ios::hex|ios::oct); return i; } 479inline ios& hex(ios& i) 480{ i.setf(ios::hex, ios::dec|ios::hex|ios::oct); return i; } 481inline 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 488extern char* form(const char*, ...); 489 490extern char* dec(long, int=0); 491extern char* dec(int, int=0); 492extern char* dec(unsigned long, int=0); 493extern char* dec(unsigned int, int=0); 494 495extern char* hex(long, int=0); 496extern char* hex(int, int=0); 497extern char* hex(unsigned long, int=0); 498extern char* hex(unsigned int, int=0); 499 500extern char* oct(long, int=0); 501extern char* oct(int, int=0); 502extern char* oct(unsigned long, int=0); 503extern char* oct(unsigned int, int=0); 504 505inline istream& WS(istream& str) { return ws(str); } 506 507 508//# 9 "test.C" 2 509 510 511class Y { 512public: 513 Y() {} 514 virtual const char *stringify() = 0; 515 virtual char *stringify2() const = 0; // { dg-error "overriding" } 516}; 517 518class X: public Y { 519public: 520 X(): Y() {} 521 const char *stringify(); // { dg-error "candidate" } 522 const char *stringify2() const; // { dg-error "candidate|conflicting return type" } 523}; 524 525char * 526X::stringify() const // { dg-error "does not match" } 527{ 528 return "stringify"; 529} 530 531const char * 532X::stringify2() // { dg-error "does not match" } 533{ 534 return "stringify2"; 535} 536 537main() 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