Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / compilerplugins / clang / test / fragiledestructor.cxx
blobe2fbfc59660d570729cca98c88fe55d575502a6b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include "sal/config.h"
12 // no warning expected
13 namespace test1
15 class Foo
17 ~Foo() { f(); }
18 void f();
22 namespace test2
24 class Foo
26 ~Foo() { f(); }
27 // expected-error@-1 {{calling virtual method from destructor, either make the virtual method final, or make this class final [loplugin:fragiledestructor]}}
28 virtual void f();
29 // expected-note@-1 {{callee method here [loplugin:fragiledestructor]}}
33 // no warning expected
34 namespace test3
36 class Foo final
38 ~Foo() { f(); }
39 virtual void f();
43 namespace test4
45 struct Bar
47 virtual ~Bar();
48 virtual void f();
49 // expected-note@-1 {{callee method here [loplugin:fragiledestructor]}}
51 class Foo : public Bar
53 ~Foo() { f(); }
54 // expected-error@-1 {{calling virtual method from destructor, either make the virtual method final, or make this class final [loplugin:fragiledestructor]}}
58 // no warning expected
59 namespace test5
61 struct Bar
63 virtual ~Bar();
64 virtual void f();
66 class Foo : public Bar
68 ~Foo() { f(); }
69 virtual void f() final override;
73 // no warning expected
74 namespace test6
76 struct Bar
78 virtual ~Bar();
79 virtual void f();
81 class Foo : public Bar
83 ~Foo() { Foo::f(); }
84 virtual void f() override;
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */