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>
20 Base
& operator=(Base
const&);
22 void variadic(int, ...);
23 void cv() const volatile;
25 static void staticFn();
26 void defaults(void* = nullptr, int = 0, double = 1, Base
const& = {}, char const* = "foo");
29 struct SimpleDerived
: Base
32 f() override
// expected-error {{public virtual function just calls public parent [loplugin:unnecessaryoverride]}}
38 struct Intermediate1
: Base
42 struct MultiFunctionIntermediate2
: Base
47 struct MultiFunctionDerived
: Intermediate1
, MultiFunctionIntermediate2
49 void f() override
{ Intermediate1::f(); } // no warning
52 struct MultiClassIntermediate2
: Base
56 struct MultiClassDerived
: Intermediate1
, MultiClassIntermediate2
58 void f() override
{ Intermediate1::f(); } // no warning
61 struct DerivedDifferent
: Base
63 void variadic(int x
) { Base::variadic(x
); } // no warning
64 void cv() { Base::cv(); } // no warning
65 void ref() && { Base::ref(); } // no warning
66 void staticFn() { Base::staticFn(); } // no warning
67 void defaults(void* x1
, int x2
, double x3
, Base
const& x4
, char const* x5
)
69 Base::defaults(x1
, x2
, x3
, x4
, x5
); // no warning
73 struct DerivedSame
: Base
76 defaults( // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
77 void* x1
= 0, int x2
= (1 - 1), double x3
= 1.0, Base
const& x4
= (Base()),
81 Base::defaults(x1
, x2
, x3
, x4
, x5
);
85 struct DerivedSlightlyDifferent
: Base
87 void defaults( // no warning
88 void* x1
= nullptr, int x2
= 0, double x3
= 1, Base
const& x4
= DerivedSlightlyDifferent(),
89 char const* x5
= "foo")
91 Base::defaults(x1
, x2
, x3
, x4
, x5
);
103 template <> struct typed_flags
<E
> : is_typed_flags
<E
, 7>
110 void default1(Base
const& = SimpleDerived());
111 void default2(Base
const& = SimpleDerived());
112 void default3(Base
= Base());
113 void default4(E
= (E::E1
| E::E2
| E::E3
));
116 struct Derived2
: Base2
118 void default1(Base
const& x
= Intermediate1()) { Base2::default1(x
); } // no warning
120 default2( // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
121 Base
const& x
= SimpleDerived())
126 default3( // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
129 (Base2::default3(x
));
132 default4( // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
133 E x
= (E::E1
| E::E2
| E::E3
))
145 class Derived3
: protected Base3
148 // effectively changing access from protected to public
149 void f1() { Base3::f1(); }
152 // check the case where the method occurs more than once in a direct path up the class hierarchy
157 struct Derived4_1
: public Base4
161 struct Derived4_2
: public Derived4_1
164 f1() // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
178 struct Derived5
: public Base5_1
, public Base5_2
180 void f1() { Base5_1::f1(); } // no warning expected
187 struct Derived6
: public Base6_1
190 f1() // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
192 bool ret
= Base6_1::f1();
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */