Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / compilerplugins / clang / test / staticdynamic.cxx
blobaa6ca7559b6be4043918ae6dae6c36daee6b54ef
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 struct ClassA
12 virtual ~ClassA() {}
15 struct ClassB : public ClassA
17 void foo() const {}
20 void f1(ClassA* p1)
22 // expected-note@+1 {{static_cast here [loplugin:staticdynamic]}}
23 static_cast<ClassB*>(p1)->foo();
24 // expected-error@+1 {{dynamic_cast after static_cast [loplugin:staticdynamic]}}
25 dynamic_cast<ClassB*>(p1)->foo();
28 void f2(ClassA* p1)
30 // expected-note@+1 {{dynamic_cast here [loplugin:staticdynamic]}}
31 dynamic_cast<ClassB*>(p1)->foo();
32 // expected-error@+1 {{static_cast after dynamic_cast [loplugin:staticdynamic]}}
33 static_cast<ClassB*>(p1)->foo();
36 void f3(ClassA* p1)
38 // expected-note@+1 {{dynamic_cast here [loplugin:staticdynamic]}}
39 dynamic_cast<const ClassB*>(p1)->foo();
40 // expected-error@+1 {{static_cast after dynamic_cast [loplugin:staticdynamic]}}
41 static_cast<ClassB*>(p1)->foo();
44 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */