Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / compilerplugins / clang / test / sequentialassign.cxx
blobb7182db5c5b2964f51971fe04545b5d6fcb92f0a
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 <rtl/ustring.hxx>
12 #pragma clang diagnostic ignored "-Wunknown-warning-option" // for Clang < 13
13 #pragma clang diagnostic ignored "-Wunused-but-set-variable"
15 namespace test1
17 void f(OUString s1)
19 OUString s2 = s1;
20 // expected-error@+1 {{simplify by merging with the preceding assignment [loplugin:sequentialassign]}}
21 s2 = s2.getToken(0, '(');
25 namespace test2
27 OUString s2;
28 void f(OUString s1)
30 s2 = s1;
31 // expected-error@+1 {{simplify by merging with the preceding assignment [loplugin:sequentialassign]}}
32 s2 = s2.getToken(0, '(');
36 namespace test3
38 struct VolumeInfo
40 OUString getFileSystemName();
42 OUString aNullURL("");
43 void f(VolumeInfo _aVolumeInfo)
45 OUString aFileSysName(aNullURL);
46 // expected-error@+1 {{simplify by merging with the preceding assignment [loplugin:sequentialassign]}}
47 aFileSysName = _aVolumeInfo.getFileSystemName();
51 namespace test4
53 struct B3DVector
55 B3DVector getPerpendicular();
57 void f(B3DVector aNewVPN)
59 B3DVector aNewToTheRight = aNewVPN;
60 // expected-error@+1 {{simplify by merging with the preceding assignment [loplugin:sequentialassign]}}
61 aNewToTheRight = aNewToTheRight.getPerpendicular();
65 namespace test5
67 void f(OUString s, int x)
69 int nPos = x;
70 // expected-error@+1 {{simplify by merging with the preceding assignment [loplugin:sequentialassign]}}
71 nPos = s.indexOf("x", nPos);
75 namespace test6
77 void f()
79 OUString s2("xxxx");
80 s2 = s2.getToken(0, '('); // no warning expected
84 namespace test7
86 class Class1
88 OUString m_field1;
89 void foo(Class1& rOther)
91 OUString s = rOther.m_field1;
92 // expected-error@+1 {{simplify by merging with the preceding assignment [loplugin:sequentialassign]}}
93 s = s.copy(1, 2);
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */