31 lines · cpp
1// RUN: %clang_cc1 %s -verify -DDIAG12// RUN: %clang_cc1 %s -verify -DDIAG1 -DDIAG2 -Wdelete-non-virtual-dtor3// RUN: %clang_cc1 %s -verify -DDIAG1 -Wmost -Wno-delete-non-abstract-non-virtual-dtor4// RUN: %clang_cc1 %s -verify -DDIAG2 -Wmost -Wno-delete-abstract-non-virtual-dtor5// RUN: %clang_cc1 %s -verify -Wmost -Wno-delete-non-virtual-dtor6 7#ifndef DIAG18#ifndef DIAG29// expected-no-diagnostics10#endif11#endif12 13struct S1 {14 ~S1() {}15 virtual void abs() = 0;16};17 18void f1(S1 *s1) { delete s1; }19#ifdef DIAG120// expected-warning@-2 {{delete called on 'S1' that is abstract but has non-virtual destructor}}21#endif22 23struct S2 {24 ~S2() {}25 virtual void real() {}26};27void f2(S2 *s2) { delete s2; }28#ifdef DIAG229// expected-warning@-2 {{delete called on non-final 'S2' that has virtual functions but non-virtual destructor}}30#endif31