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/.
12 #include <rtl/ustring.hxx>
22 // expected-error@-1 {{buried assignment, rather put on own line [loplugin:buriedassign]}}
23 int y
= x
= 1; // no warning expected
26 // expected-error@-1 {{buried assignment, rather put on own line [loplugin:buriedassign]}}
29 { // expected-error@-1 {{buried assignment, rather put on own line [loplugin:buriedassign]}}
31 std::map
<int, int> map1
;
33 // expected-error@-1 {{buried assignment, rather put on own line [loplugin:buriedassign]}}
46 MyInt(MyInt
const&) = default;
47 MyInt
& operator=(MyInt
const&) = default;
48 MyInt
& operator=(int) { return *this; }
49 bool operator<(MyInt
const& other
) const { return x
< other
.x
; }
58 // expected-error@-1 {{buried assignment, rather put on own line [loplugin:buriedassign]}}
59 MyInt y
= x
= 1; // no warning expected
62 // expected-error@-1 {{buried assignment, rather put on own line [loplugin:buriedassign]}}
64 z
= x
; // no warning expected
65 std::map
<MyInt
, int> map1
;
67 // expected-error@-1 {{buried assignment, rather put on own line [loplugin:buriedassign]}}
73 void main(OUString sUserAutoCorrFile
, OUString sExt
)
76 if (sUserAutoCorrFile
== "xxx")
77 sRet
= sUserAutoCorrFile
; // no warning expected
78 if (sUserAutoCorrFile
== "yyy")
79 (sRet
= sUserAutoCorrFile
)
80 += sExt
; // expected-error@-1 {{buried assignment, rather put on own line [loplugin:buriedassign]}}
84 // no warning expected
91 std::unique_ptr
<Task
> pop();
95 std::unique_ptr
<Task
> pTask
;
96 while ((pTask
= pop()))
103 void main(OUString sUserAutoCorrFile
, int* p2
)
107 if (sUserAutoCorrFile
== "yyy" && (p1
= p2
))
108 sRet
= sUserAutoCorrFile
;
109 if (sUserAutoCorrFile
== "yyy" && nullptr != (p1
= p2
))
110 sRet
= sUserAutoCorrFile
;
111 // expected-error@+1 {{buried assignment, rather put on own line [loplugin:buriedassign]}}
112 if (nullptr != (p1
= p2
))
113 sRet
= sUserAutoCorrFile
;
114 // expected-error@+1 {{buried assignment, rather put on own line [loplugin:buriedassign]}}
115 if ((p1
= p2
) != nullptr)
116 sRet
= sUserAutoCorrFile
;
117 // expected-error@+1 {{buried assignment, rather put on own line [loplugin:buriedassign]}}
119 sRet
= sUserAutoCorrFile
;
120 // expected-error@+1 {{buried assignment, rather put on own line [loplugin:buriedassign]}}
121 if ((p1
= p2
) && sUserAutoCorrFile
== "yyy")
122 sRet
= sUserAutoCorrFile
;
123 // expected-error@+1 {{buried assignment, rather put on own line [loplugin:buriedassign]}}
124 if ((p1
= p2
) || sUserAutoCorrFile
== "yyy")
125 sRet
= sUserAutoCorrFile
;
126 // expected-error@+1 {{buried assignment, rather put on own line [loplugin:buriedassign]}}
127 if ((p1
= p2
) && sUserAutoCorrFile
== "yyy")
128 sRet
= sUserAutoCorrFile
;
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */