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 <o3tl/typed_flags_set.hxx>
19 NO_CLASH
// expected-error {{write NO_CLASH [loplugin:unusedenumconstants]}}
21 NameClashMode eNameClashMode
= NO_CLASH
;
28 Modules
= 0x01, // expected-error {{read Modules [loplugin:unusedenumconstants]}}
29 Top
= 0x02, // expected-error {{write Top [loplugin:unusedenumconstants]}}
30 Bottom
= 0x04, // expected-error {{read Bottom [loplugin:unusedenumconstants]}}
31 Left
= 0x04, // expected-error {{write Left [loplugin:unusedenumconstants]}}
35 template <> struct typed_flags
<BrowseMode
> : is_typed_flags
<BrowseMode
, 0xf>
40 int test2(BrowseMode nMode
)
42 if (nMode
& BrowseMode::Modules
)
44 g_flags
|= BrowseMode::Top
;
47 bool test2b(BrowseMode nMode
) { return bool(nMode
& BrowseMode::Bottom
); }
48 BrowseMode
test2c() { return BrowseMode::Left
; }
52 One
= 0x01, // expected-error {{write One [loplugin:unusedenumconstants]}}
53 Two
= 0x02 // expected-error {{write Two [loplugin:unusedenumconstants]}}
57 template <> struct typed_flags
<Enum3
> : is_typed_flags
<Enum3
, 0x3>
61 void test3_foo(Enum3
);
62 void test3() { test3_foo(Enum3::One
| Enum3::Two
); }
68 ONE
, // expected-error {{write ONE [loplugin:unusedenumconstants]}}
75 struct Test4
: public Test4Base
78 : Test4Base(Enum4::ONE
)
84 //-----------------------------------------------------------------------------------
86 // check that conditional operator walks up the tree
91 ONE
, // expected-error {{write ONE [loplugin:unusedenumconstants]}}
92 TWO
// expected-error {{write TWO [loplugin:unusedenumconstants]}}
95 Enum
foo(int x
) { return x
== 1 ? Enum::ONE
: Enum::TWO
; }
98 //-----------------------------------------------------------------------------------
99 // Ignore a common pattern that does not introduce any new information, merely removes
103 Modules
= 0x01, // expected-error {{write Modules [loplugin:unusedenumconstants]}}
108 template <> struct typed_flags
<Enum6
> : is_typed_flags
<Enum6
, 0x03>
114 Enum6 foo
= Enum6::Modules
;
116 foo
&= (~Enum6::Top
);
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */