1 // RUN: %clang_cc1 %s -verify -DDIAG1
2 // RUN: %clang_cc1 %s -verify -DDIAG1 -DDIAG2 -Wdelete-non-virtual-dtor
3 // RUN: %clang_cc1 %s -verify -DDIAG1         -Wmost -Wno-delete-non-abstract-non-virtual-dtor
4 // RUN: %clang_cc1 %s -verify         -DDIAG2 -Wmost -Wno-delete-abstract-non-virtual-dtor
5 // RUN: %clang_cc1 %s -verify                 -Wmost -Wno-delete-non-virtual-dtor
6 
7 #ifndef DIAG1
8 #ifndef DIAG2
9 // expected-no-diagnostics
10 #endif
11 #endif
12 
13 struct S1 {
~S1S114   ~S1() {}
15   virtual void abs() = 0;
16 };
17 
f1(S1 * s1)18 void f1(S1 *s1) { delete s1; }
19 #ifdef DIAG1
20 // expected-warning@-2 {{delete called on 'S1' that is abstract but has non-virtual destructor}}
21 #endif
22 
23 struct S2 {
~S2S224   ~S2() {}
realS225   virtual void real() {}
26 };
f2(S2 * s2)27 void f2(S2 *s2) { delete s2; }
28 #ifdef DIAG2
29 // expected-warning@-2 {{delete called on non-final 'S2' that has virtual functions but non-virtual destructor}}
30 #endif
31