111
|
1 // { dg-do compile }
|
|
2 // { dg-options "-Weffc++ -Wno-non-virtual-dtor" }
|
|
3
|
|
4 // Warn when a class has virtual functions and accessible non-virtual
|
|
5 // destructor, in which case it would be possible but unsafe to delete
|
|
6 // an instance of a derived class through a pointer to the base class.
|
|
7
|
|
8 struct A
|
|
9 {
|
|
10 protected:
|
|
11 ~A();
|
|
12 public:
|
|
13 virtual void f() = 0;
|
|
14 };
|
|
15
|
|
16 struct B
|
|
17 {
|
|
18 private:
|
|
19 ~B();
|
|
20 public:
|
|
21 virtual void f() = 0;
|
|
22 };
|
|
23
|
|
24 struct C
|
|
25 {
|
|
26 virtual void f() = 0;
|
|
27 };
|
|
28
|
|
29 struct D
|
|
30 {
|
|
31 ~D();
|
|
32 virtual void f() = 0;
|
|
33 };
|
|
34
|
|
35 struct E;
|
|
36
|
|
37 struct F
|
|
38 {
|
|
39 protected:
|
|
40 friend class E;
|
|
41 ~F();
|
|
42 public:
|
|
43 virtual void f() = 0;
|
|
44 };
|
|
45
|
|
46 struct G
|
|
47 {
|
|
48 private:
|
|
49 friend class E;
|
|
50 ~G();
|
|
51 public:
|
|
52 virtual void f() = 0;
|
|
53 };
|
|
54
|
|
55 struct H {};
|
|
56
|
|
57 struct I1 : H
|
|
58 {};
|
|
59 struct I2 : private H
|
|
60 {};
|
|
61
|
|
62 struct J1 : H
|
|
63 { virtual ~J1 ();};
|
|
64 struct J2 : private H
|
|
65 { virtual ~J2 ();};
|
|
66
|
|
67 struct K
|
|
68 {
|
|
69 virtual void k ();
|
|
70 };
|
|
71
|
|
72 struct L1 : K
|
|
73 {virtual ~L1 ();};
|
|
74 struct L2 : private K
|
|
75 {virtual ~L2 ();};
|