Fix typo
[LibreOffice.git] / compilerplugins / clang / test / rangedforcopy.cxx
blobf9c027bb84f85b1b9f1719d610cbdc7b9c6c4ab8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
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/.
8 */
10 #include <vector>
11 #include <rtl/ustring.hxx>
12 #include <svl/typedwhich.hxx>
14 struct S
16 int i1;
17 int i2;
20 void f(S const (&a)[2])
22 // expected-error-re@+1 {{Loop variable passed by value, pass by reference instead, e.g. 'const {{(struct )?}}S&' [loplugin:rangedforcopy]}}
23 for (auto i : a)
25 (void)i;
27 for (auto[i1, i2] : a)
29 (void)i1;
30 (void)i2;
34 void f(std::vector<bool> const& v)
36 for (auto b : v)
38 (void)b;
42 // no warning expected
43 class SvxFontItem;
44 constexpr TypedWhichId<SvxFontItem> EE_CHAR_FONTINFO1(12);
45 constexpr TypedWhichId<SvxFontItem> EE_CHAR_FONTINFO2(13);
46 void f2()
48 for (auto nWhich : { EE_CHAR_FONTINFO1, EE_CHAR_FONTINFO2 })
49 (void)nWhich;
52 // no warning expected
53 void f3()
55 for (rtl::OUStringChar c : { 'a', 'b' })
56 (void)c;
59 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */