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
72 #if CLANG_VERSION >= 30900 // cf. corresponding condition in Plugin::checkIdenticalDefaultArguments
74 defaults( // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
75 void* x1
= 0, int x2
= (1 - 1), double x3
= 1.0, Base
const& x4
= (Base()),
79 Base::defaults(x1
, x2
, x3
, x4
, x5
);
84 struct DerivedSlightlyDifferent
: Base
86 void defaults( // no warning
87 void* x1
= nullptr, int x2
= 0, double x3
= 1, Base
const& x4
= DerivedSlightlyDifferent(),
88 char const* x5
= "foo")
90 Base::defaults(x1
, x2
, x3
, x4
, x5
);
102 template <> struct typed_flags
<E
> : is_typed_flags
<E
, 7>
109 void default1(Base
const& = SimpleDerived());
110 void default2(Base
const& = SimpleDerived());
111 void default3(Base
= Base());
112 void default4(E
= (E::E1
| E::E2
| E::E3
));
115 struct Derived2
: Base2
117 void default1(Base
const& x
= Intermediate1()) { Base2::default1(x
); } // no warning
119 default2( // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
120 Base
const& x
= SimpleDerived())
125 default3( // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
128 (Base2::default3(x
));
131 default4( // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
132 E x
= (E::E1
| E::E2
| E::E3
))
144 class Derived3
: protected Base3
147 // effectively changing access from protected to public
148 void f1() { Base3::f1(); }
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */