xref: /openbsd-src/gnu/usr.bin/gcc/gcc/testsuite/g++.old-deja/g++.oliva/delete1.C (revision c87b03e512fc05ed6e0222f6fb0ae86264b1d05b)
1 // Build don't link:
2 
3 // Copyright (C) 1999, 2001 Free Software Foundation
4 
5 // by Alexandre Oliva <oliva@dcc.unicamp.br>
6 // simplified from bug report by K. Haley <khaley@bigfoot.com>
7 // based on analysis by Martin v. Loewis
8 
9 // [class.dtor]/11: delete must be implicitly checked for
10 // accessibility only in the definition of virtual destructors,
11 // implicitly defined or not.
12 
13 struct foo {
foofoo14   foo() {}
15 private:
deletefoo16   void operator delete(void *) {} // ERROR - private
17 } foo_;
18 
19 struct bar : foo {
~barbar20   ~bar() {
21     delete this; // ERROR - delete is private
22     // An implicit invocation of delete is emitted in destructors, but
23     // it should only be checked in virtual destructors
24   } // gets bogus error - not virtual
25 } bar_;
26 
27 struct baz : foo {
~bazbaz28   virtual ~baz() {} // ERROR - delete is private in vdtor
29 } baz_;
30 
31 struct bad : baz {} bad_; // ERROR - delete is private in vdtor
32