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 <rtl/ustring.hxx>
12 /*int foo() { return 1; }*/
15 void call_const_ref(int const &);
17 void call_value(OUString
);
18 void call_const_ref(OUString
const &);
19 void call_ref(OUString
&);
21 template<typename T
> void f() {
22 int i
= sizeof (T
) + 1; // expected-error {{var used only once, should be inlined or declared const [loplugin:oncevar]}}
23 call_value(i
); // expected-note {{used here [loplugin:oncevar]}}
25 template void f
<int>(); // needed for clang-cl
28 void method1(const Foo
**);
34 if ( (i = foo()) == 0 ) {
40 int i1
= 2; // expected-error {{var used only once, should be inlined or declared const [loplugin:oncevar]}}
41 call_value(i1
); // expected-note {{used here [loplugin:oncevar]}}
42 int i2
= 2; // expected-error {{var used only once, should be inlined or declared const [loplugin:oncevar]}}
43 call_const_ref(i2
); // expected-note {{used here [loplugin:oncevar]}}
45 // don't expect warnings here
51 OUString
s1("xxx"); // expected-error {{var used only once, should be inlined or declared const [loplugin:oncevar]}}
52 call_value(s1
); // expected-note {{used here [loplugin:oncevar]}}
53 OUString
s2("xxx"); // expected-error {{var used only once, should be inlined or declared const [loplugin:oncevar]}}
54 call_const_ref(s2
); // expected-note {{used here [loplugin:oncevar]}}
56 // don't expect warnings here
59 OUString
const s4("xxx");
62 const Foo
* pInternalArgs
[] = { nullptr };
63 method1(pInternalArgs
);
66 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */