1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
10 #include <sal/config.h>
12 #include <config_clang.h>
13 #include <o3tl/typed_flags_set.hxx>
19 void variadic(int, ...);
20 void cv() const volatile;
22 static void staticFn();
23 void defaults(void* = nullptr, int = 0, double = 1, Base
const& = {}, char const* = "foo");
26 struct SimpleDerived
: Base
29 f() override
// expected-error {{public virtual function just calls public parent [loplugin:unnecessaryoverride]}}
35 struct Intermediate1
: Base
39 struct MultiFunctionIntermediate2
: Base
44 struct MultiFunctionDerived
: Intermediate1
, MultiFunctionIntermediate2
46 void f() override
{ Intermediate1::f(); } // no warning
49 struct MultiClassIntermediate2
: Base
53 struct MultiClassDerived
: Intermediate1
, MultiClassIntermediate2
55 void f() override
{ Intermediate1::f(); } // no warning
58 struct DerivedDifferent
: Base
60 void variadic(int x
) { Base::variadic(x
); } // no warning
61 void cv() { Base::cv(); } // no warning
62 void ref() && { Base::ref(); } // no warning
63 void staticFn() { Base::staticFn(); } // no warning
64 void defaults(void* x1
, int x2
, double x3
, Base
const& x4
, char const* x5
)
66 Base::defaults(x1
, x2
, x3
, x4
, x5
); // no warning
70 struct DerivedSame
: Base
73 defaults( // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
74 void* x1
= 0, int x2
= (1 - 1), double x3
= 1.0, Base
const& x4
= (Base()),
78 Base::defaults(x1
, x2
, x3
, x4
, x5
);
82 struct DerivedSlightlyDifferent
: Base
84 void defaults( // no warning
85 void* x1
= nullptr, int x2
= 0, double x3
= 1, Base
const& x4
= DerivedSlightlyDifferent(),
86 char const* x5
= "foo")
88 Base::defaults(x1
, x2
, x3
, x4
, x5
);
100 template <> struct typed_flags
<E
> : is_typed_flags
<E
, 7>
107 void default1(Base
const& = SimpleDerived());
108 void default2(Base
const& = SimpleDerived());
109 void default3(Base
= Base());
110 void default4(E
= (E::E1
| E::E2
| E::E3
));
113 struct Derived2
: Base2
115 void default1(Base
const& x
= Intermediate1()) { Base2::default1(x
); } // no warning
117 default2( // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
118 Base
const& x
= SimpleDerived())
123 default3( // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
126 (Base2::default3(x
));
129 default4( // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
130 E x
= (E::E1
| E::E2
| E::E3
))
142 class Derived3
: protected Base3
145 // effectively changing access from protected to public
146 void f1() { Base3::f1(); }
149 // check the case where the method occurs more than once in a direct path up the class hierarchy
154 struct Derived4_1
: public Base4
158 struct Derived4_2
: public Derived4_1
161 f1() // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
175 struct Derived5
: public Base5_1
, public Base5_2
177 void f1() { Base5_1::f1(); } // no warning expected
184 struct Derived6
: public Base6_1
187 f1() // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
189 bool ret
= Base6_1::f1();
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */