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 "sal/config.h"
12 #include "rtl/ustring.hxx"
13 #include "tools/color.hxx"
16 #include <initializer_list>
19 void method1(OUString
const&); // expected-note {{in call to method here [loplugin:redundantfcast]}}
26 void func1(Foo
const& f
); // expected-note {{in call to method here [loplugin:redundantfcast]}}
37 Polygon
const&); // expected-note {{in call to method here [loplugin:redundantfcast]}}
41 void ImplWritePolyPolygonRecord(const tools::PolyPolygon
& rPolyPoly
);
47 s
); // expected-error-re@-1 {{redundant functional cast from '{{(rtl::)?}}OUString' to '{{(rtl::)?}}OUString' [loplugin:redundantfcast]}}
50 s
); // expected-error-re@-1 {{redundant functional cast from '{{(rtl::)?}}OUString' to 'T1' (aka '{{(rtl::)?}}OUString') [loplugin:redundantfcast]}}
51 using T2
= OUString
const;
53 s
); // expected-error-re@-1 {{redundant functional cast from '{{(rtl::)?}}OUString' to 'T2' (aka 'const {{(rtl::?)}}OUString') [loplugin:redundantfcast]}}
55 (void)std::unique_ptr
<int>(std::unique_ptr
<int>(
56 new int{})); // expected-error@-1 {{redundant functional cast from 'std::unique_ptr<int>' to 'std::unique_ptr<int>' [loplugin:redundantfcast]}}
60 s1
)); // expected-error-re@-1 {{redundant functional cast from '{{(rtl::)?}}OUString' to '{{(rtl::)?}}OUString' [loplugin:redundantfcast]}}
63 s1
); // expected-error-re@-1 {{redundant functional cast from '{{(rtl::)?}}OUString' to '{{(rtl::)?}}OUString' [loplugin:redundantfcast]}}
68 col1
); // expected-error@-1 {{redundant functional cast from 'Color' to 'Color' [loplugin:redundantfcast]}}
73 foo
)); // expected-error@-1 {{redundant functional cast from 'Foo' to 'Foo' [loplugin:redundantfcast]}}
75 const tools::Polygon aPolygon
;
76 ImplWritePolyPolygonRecord(tools::PolyPolygon(tools::Polygon(
77 aPolygon
))); // expected-error@-1 {{redundant functional cast from 'const tools::Polygon' to 'tools::Polygon' in construct expression [loplugin:redundantfcast]}}
86 foo
); // expected-error@-1 {{redundant functional cast from 'Foo' to 'Foo' [loplugin:redundantfcast]}}
93 void f1(std::function
<void()> x
);
96 // expected-error-re@+1 {{redundant functional cast {{.+}} [loplugin:redundantfcast]}}
97 f1(std::function([&]() {}));
102 void f1(std::function
<void(int)>);
103 void f1(std::function
<void(long)>);
106 f1(std::function
<void(long)>([&](int) {})); // should not warn here
112 // expected-note@+1 6 {{in call to method here [loplugin:redundantfcast]}}
113 void f1(std::initializer_list
<int> const&);
114 // expected-note@+1 6 {{in call to method here [loplugin:redundantfcast]}}
115 template <typename T
> void f2(std::initializer_list
<T
> const&);
116 // expected-note@+1 4 {{in call to method here [loplugin:redundantfcast]}}
117 template <typename T
> void f3(T
const&);
118 // expected-note@+1 4 {{in call to method here [loplugin:redundantfcast]}}
119 template <typename
... T
> void f4(T
const&...);
121 void g(std::initializer_list
<int> il
)
128 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
129 f1(std::initializer_list
<int>(il
));
130 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
131 f2(std::initializer_list
<int>(il
));
132 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
133 f3(std::initializer_list
<int>(il
));
134 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
135 f4(std::initializer_list
<int>(il
));
136 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
137 f5(0, std::initializer_list
<int>(il
));
139 f1(std::initializer_list
<int>{}); // should warn, but not modelled as CXXFunctionalCastExpr
140 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
141 f1(std::initializer_list
<int>({}));
143 f2(std::initializer_list
<int>{}); // should warn, but not modelled as CXXFunctionalCastExpr
144 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
145 f2(std::initializer_list
<int>({}));
147 f3(std::initializer_list
<int>{}); // (not modelled as CXXFunctionalCastExpr anyway)
148 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
149 f3(std::initializer_list
<int>({})); // arguably rather subtle, remove "("...")"
151 f4(std::initializer_list
<int>{}); // (not modelled as CXXFunctionalCastExpr anyway)
152 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
153 f4(std::initializer_list
<int>({})); // arguably rather subtle, remove "("...")"
154 // f5(0, {}); //error
155 f5(0, std::initializer_list
<int>{}); // (not modelled as CXXFunctionalCastExpr anyway)
156 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
157 f5(0, std::initializer_list
<int>({})); // arguably rather subtle, remove "("...")"
159 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
160 f1(std::initializer_list
<int>{ 1 });
161 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
162 f1(std::initializer_list
<int>({ 1 }));
164 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
165 f2(std::initializer_list
<int>{ 1 });
166 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
167 f2(std::initializer_list
<int>({ 1 }));
169 f3(std::initializer_list
<int>{ 1 });
170 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
171 f3(std::initializer_list
<int>({ 1 })); // arguably rather subtle, remove "("...")"
173 f4(std::initializer_list
<int>{ 1 });
174 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
175 f4(std::initializer_list
<int>({ 1 })); // arguably rather subtle, remove "("...")"
176 // f5(0, {1}); //error
177 f5(0, std::initializer_list
<int>{ 1 });
178 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
179 f5(0, std::initializer_list
<int>({ 1 })); // arguably rather subtle, remove "("...")"
181 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
182 f1(std::initializer_list
<int>{ 1, 2, 3 });
183 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
184 f1(std::initializer_list
<int>({ 1, 2, 3 }));
186 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
187 f2(std::initializer_list
<int>{ 1, 2, 3 });
188 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
189 f2(std::initializer_list
<int>({ 1, 2, 3 }));
190 // f3({1, 2, 3}); //error
191 f3(std::initializer_list
<int>{ 1, 2, 3 });
192 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
193 f3(std::initializer_list
<int>({ 1, 2, 3 })); // arguably rather subtle, remove "("...")"
194 // f4({1, 2, 3}); //error
195 f4(std::initializer_list
<int>{ 1, 2, 3 });
196 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
197 f4(std::initializer_list
<int>({ 1, 2, 3 })); // arguably rather subtle, remove "("...")"
198 // f5(0, {1, 2, 3}); //error
199 f5(0, std::initializer_list
<int>{ 1, 2, 3 });
200 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
201 f5(0, std::initializer_list
<int>({ 1, 2, 3 })); // arguably rather subtle, remove "("...")"
207 class Primitive2DContainer
210 struct GroupPrimitive
212 GroupPrimitive(Primitive2DContainer
&&);
215 const Primitive2DContainer
& getChildren();
219 // no warning expected, we have to create a temporary for this constructor
220 GroupPrimitive
aGroup((Primitive2DContainer(getChildren())));
224 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */