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 #pragma clang diagnostic ignored "-Wunknown-warning-option" // for Clang < 13
13 #pragma clang diagnostic ignored "-Wunused-but-set-variable"
17 int i
= 2; // expected-error {{can reduce scope of var [loplugin:reducevarscope]}}
19 i
= 3; // expected-note {{used here [loplugin:reducevarscope]}}
21 int j
= 2; // expected-error {{can reduce scope of var [loplugin:reducevarscope]}}
23 j
= 3; // expected-note {{used here [loplugin:reducevarscope]}}
25 j
= 4; // expected-note {{used here [loplugin:reducevarscope]}}
30 // negative test - seen inside a loop
34 for (int j
= 1; j
< 10; ++j
)
40 // negative test - initial assignment from non-constant
67 // negative test - seen in 2 child blocks
79 // TODO negative test - storing pointer to OUString data
83 // const sal_Unicode* p = nullptr;
91 // negative test - passing var into lambda
95 auto l1
= [&]() { i
= 1; };
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */