bump product version to 6.3.0.0.beta1
[LibreOffice.git] / compilerplugins / clang / test / redundantfcast.cxx
blob13e09b5e05b63cdb168b55b9f5eaf1f8aaf07bd2
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 "sal/config.h"
12 #include <memory>
14 #include "rtl/ustring.hxx"
15 #include "tools/color.hxx"
17 void method1(OUString const&); // expected-note {{in call to method here [loplugin:redundantfcast]}}
19 struct Foo
21 Foo(int) {}
24 void func1(Foo const& f); // expected-note {{in call to method here [loplugin:redundantfcast]}}
26 namespace tools
28 struct Polygon
30 Polygon() = default;
32 struct PolyPolygon
34 PolyPolygon(
35 Polygon const&); // expected-note {{in call to method here [loplugin:redundantfcast]}}
39 void ImplWritePolyPolygonRecord(const tools::PolyPolygon& rPolyPoly);
41 int main()
43 OUString s;
44 (void)OUString(
45 s); // expected-error@-1 {{redundant functional cast from 'rtl::OUString' to 'rtl::OUString' [loplugin:redundantfcast]}}
46 using T1 = OUString;
47 (void)T1(
48 s); // expected-error@-1 {{redundant functional cast from 'rtl::OUString' to 'T1' (aka 'rtl::OUString') [loplugin:redundantfcast]}}
49 using T2 = OUString const;
50 (void)T2(
51 s); // expected-error@-1 {{redundant functional cast from 'rtl::OUString' to 'T2' (aka 'const rtl::OUString') [loplugin:redundantfcast]}}
53 (void)std::unique_ptr<int>(std::unique_ptr<int>(
54 new int{})); // expected-error@-1 {{redundant functional cast from 'std::unique_ptr<int>' to 'std::unique_ptr<int>' [loplugin:redundantfcast]}}
56 OUString s1;
57 method1(OUString(
58 s1)); // expected-error@-1 {{redundant functional cast from 'rtl::OUString' to 'rtl::OUString' [loplugin:redundantfcast]}}
59 // expected-error@-2 {{redundant functional cast from 'rtl::OUString' to 'rtl::OUString' [loplugin:redundantfcast]}}
60 OUString s2;
61 s2 = OUString(
62 s1); // expected-error@-1 {{redundant functional cast from 'rtl::OUString' to 'rtl::OUString' [loplugin:redundantfcast]}}
64 Color col1;
65 Color col2 = Color(
66 col1); // expected-error@-1 {{redundant functional cast from 'Color' to 'Color' [loplugin:redundantfcast]}}
67 (void)col2;
69 Foo foo(1);
70 func1(Foo(
71 foo)); // expected-error@-1 {{redundant functional cast from 'Foo' to 'Foo' [loplugin:redundantfcast]}} expected-error@-1 {{redundant functional cast from 'Foo' to 'Foo' [loplugin:redundantfcast]}}
73 const tools::Polygon aPolygon;
74 ImplWritePolyPolygonRecord(tools::PolyPolygon(tools::Polygon(
75 aPolygon))); // expected-error@-1 {{redundant functional cast from 'const tools::Polygon' to 'tools::Polygon' [loplugin:redundantfcast]}} expected-error@-1 {{redundant functional cast from 'const tools::Polygon' to 'tools::Polygon' [loplugin:redundantfcast]}}
78 class Class1
80 Foo foo;
81 Foo func2()
83 return Foo(
84 foo); // expected-error@-1 {{redundant functional cast from 'Foo' to 'Foo' [loplugin:redundantfcast]}} expected-error@-1 {{redundant functional cast from 'Foo' to 'Foo' [loplugin:redundantfcast]}}
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */