http://gcc.gnu.org/ml/gcc-patches/2008-02/msg00110.html
[official-gcc.git] / gcc / testsuite / g++.dg / warn / Wnvdtor-2.C
blobcd078ac052138863f93131e9f3e8cea5883a1f8d
1 // PR c++/7302
2 // { dg-do compile }
3 // { dg-options "-Wnon-virtual-dtor" }
5 // Warn when a class has virtual functions and accessible non-virtual
6 // destructor, in which case it would be possible but unsafe to delete
7 // an instance of a derived class through a pointer to the base class.
9 struct A
10 { // { dg-bogus "non-virtual destructor" }
11 protected:
12   ~A();
13 public:
14   virtual void f() = 0;
17 struct B
18 { // { dg-bogus "non-virtual destructor" }
19 private:
20   ~B();
21 public:
22   virtual void f() = 0;
25 struct C
26 { // { dg-warning "non-virtual destructor" }
27   virtual void f() = 0;
30 struct D
31 { // { dg-warning "non-virtual destructor" }
32   ~D();
33   virtual void f() = 0;
36 struct E;
38 struct F
39 { // { dg-warning "non-virtual destructor" }
40 protected:
41   friend class E;
42   ~F();
43 public:
44   virtual void f() = 0;
47 struct G
48 { // { dg-warning "non-virtual destructor" }
49 private:
50   friend class E;
51   ~G();
52 public:
53   virtual void f() = 0;