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@-1 {{redundant functional cast from 'rtl::OUString' to 'rtl::OUString' [loplugin:redundantfcast]}}
50 s
); // expected-error@-1 {{redundant functional cast from 'rtl::OUString' to 'T1' (aka 'rtl::OUString') [loplugin:redundantfcast]}}
51 using T2
= OUString
const;
53 s
); // expected-error@-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@-1 {{redundant functional cast from 'rtl::OUString' to 'rtl::OUString' [loplugin:redundantfcast]}}
63 s1
); // expected-error@-1 {{redundant functional cast from 'rtl::OUString' to 'rtl::OUString' [loplugin:redundantfcast]}}
67 col1
); // expected-error@-1 {{redundant functional cast from 'Color' to 'Color' [loplugin:redundantfcast]}}
72 foo
)); // expected-error@-1 {{redundant functional cast from 'Foo' to 'Foo' [loplugin:redundantfcast]}}
74 const tools::Polygon aPolygon
;
75 ImplWritePolyPolygonRecord(tools::PolyPolygon(tools::Polygon(
76 aPolygon
))); // expected-error@-1 {{redundant functional cast from 'const tools::Polygon' to 'tools::Polygon' [loplugin:redundantfcast]}}
85 foo
); // expected-error@-1 {{redundant functional cast from 'Foo' to 'Foo' [loplugin:redundantfcast]}}
92 void f1(std::function
<void()> x
);
95 // expected-error-re@+1 {{redundant functional cast {{.+}} [loplugin:redundantfcast]}}
96 f1(std::function([&]() {}));
101 void f1(std::function
<void(int)>);
102 void f1(std::function
<void(long)>);
105 f1(std::function
<void(long)>([&](int) {})); // should not warn here
111 // expected-note@+1 6 {{in call to method here [loplugin:redundantfcast]}}
112 void f1(std::initializer_list
<int> const&);
113 // expected-note@+1 6 {{in call to method here [loplugin:redundantfcast]}}
114 template <typename T
> void f2(std::initializer_list
<T
> const&);
115 // expected-note@+1 4 {{in call to method here [loplugin:redundantfcast]}}
116 template <typename T
> void f3(T
const&);
117 // expected-note@+1 4 {{in call to method here [loplugin:redundantfcast]}}
118 template <typename
... T
> void f4(T
const&...);
120 void g(std::initializer_list
<int> il
)
127 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
128 f1(std::initializer_list
<int>(il
));
129 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
130 f2(std::initializer_list
<int>(il
));
131 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
132 f3(std::initializer_list
<int>(il
));
133 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
134 f4(std::initializer_list
<int>(il
));
135 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
136 f5(0, std::initializer_list
<int>(il
));
138 f1(std::initializer_list
<int>{}); // should warn, but not modelled as CXXFunctionalCastExpr
139 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
140 f1(std::initializer_list
<int>({}));
142 f2(std::initializer_list
<int>{}); // should warn, but not modelled as CXXFunctionalCastExpr
143 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
144 f2(std::initializer_list
<int>({}));
146 f3(std::initializer_list
<int>{}); // (not modelled as CXXFunctionalCastExpr anyway)
147 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
148 f3(std::initializer_list
<int>({})); // arguably rather subtle, remove "("...")"
150 f4(std::initializer_list
<int>{}); // (not modelled as CXXFunctionalCastExpr anyway)
151 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
152 f4(std::initializer_list
<int>({})); // arguably rather subtle, remove "("...")"
153 // f5(0, {}); //error
154 f5(0, std::initializer_list
<int>{}); // (not modelled as CXXFunctionalCastExpr anyway)
155 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
156 f5(0, std::initializer_list
<int>({})); // arguably rather subtle, remove "("...")"
158 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
159 f1(std::initializer_list
<int>{ 1 });
160 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
161 f1(std::initializer_list
<int>({ 1 }));
163 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
164 f2(std::initializer_list
<int>{ 1 });
165 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
166 f2(std::initializer_list
<int>({ 1 }));
168 f3(std::initializer_list
<int>{ 1 });
169 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
170 f3(std::initializer_list
<int>({ 1 })); // arguably rather subtle, remove "("...")"
172 f4(std::initializer_list
<int>{ 1 });
173 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
174 f4(std::initializer_list
<int>({ 1 })); // arguably rather subtle, remove "("...")"
175 // f5(0, {1}); //error
176 f5(0, std::initializer_list
<int>{ 1 });
177 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
178 f5(0, std::initializer_list
<int>({ 1 })); // arguably rather subtle, remove "("...")"
180 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
181 f1(std::initializer_list
<int>{ 1, 2, 3 });
182 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
183 f1(std::initializer_list
<int>({ 1, 2, 3 }));
185 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
186 f2(std::initializer_list
<int>{ 1, 2, 3 });
187 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
188 f2(std::initializer_list
<int>({ 1, 2, 3 }));
189 // f3({1, 2, 3}); //error
190 f3(std::initializer_list
<int>{ 1, 2, 3 });
191 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
192 f3(std::initializer_list
<int>({ 1, 2, 3 })); // arguably rather subtle, remove "("...")"
193 // f4({1, 2, 3}); //error
194 f4(std::initializer_list
<int>{ 1, 2, 3 });
195 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
196 f4(std::initializer_list
<int>({ 1, 2, 3 })); // arguably rather subtle, remove "("...")"
197 // f5(0, {1, 2, 3}); //error
198 f5(0, std::initializer_list
<int>{ 1, 2, 3 });
199 // expected-error@+1 {{redundant functional cast from 'std::initializer_list<int>' to 'std::initializer_list<int>' [loplugin:redundantfcast]}}
200 f5(0, std::initializer_list
<int>({ 1, 2, 3 })); // arguably rather subtle, remove "("...")"
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */