Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / compilerplugins / clang / test / redundantfcast.cxx
blobda7e8be5a027a59b8e873a6b3608b38395d57fba
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 int main()
28 OUString s;
29 (void)OUString(
30 s); // expected-error@-1 {{redundant functional cast from 'rtl::OUString' to 'rtl::OUString' [loplugin:redundantfcast]}}
31 using T1 = OUString;
32 (void)T1(
33 s); // expected-error@-1 {{redundant functional cast from 'rtl::OUString' to 'T1' (aka 'rtl::OUString') [loplugin:redundantfcast]}}
34 using T2 = OUString const;
35 (void)T2(
36 s); // expected-error@-1 {{redundant functional cast from 'rtl::OUString' to 'T2' (aka 'const rtl::OUString') [loplugin:redundantfcast]}}
38 (void)std::unique_ptr<int>(std::unique_ptr<int>(
39 new int{})); // expected-error@-1 {{redundant functional cast from 'std::unique_ptr<int>' to 'std::unique_ptr<int>' [loplugin:redundantfcast]}}
41 OUString s1;
42 method1(OUString(
43 s1)); // expected-error@-1 {{redundant functional cast from 'rtl::OUString' to 'rtl::OUString' [loplugin:redundantfcast]}}
44 // expected-error@-2 {{redundant functional cast from 'rtl::OUString' to 'rtl::OUString' [loplugin:redundantfcast]}}
45 OUString s2;
46 s2 = OUString(
47 s1); // expected-error@-1 {{redundant functional cast from 'rtl::OUString' to 'rtl::OUString' [loplugin:redundantfcast]}}
49 Color col1;
50 Color col2 = Color(
51 col1); // expected-error@-1 {{redundant functional cast from 'Color' to 'Color' [loplugin:redundantfcast]}}
52 (void)col2;
54 Foo foo(1);
55 func1(Foo(
56 foo)); // expected-error@-1 {{redundant functional cast from 'Foo' to 'Foo' [loplugin:redundantfcast]}}
59 class Class1
61 Foo foo;
62 Foo func2()
64 return Foo(
65 foo); // expected-error@-1 {{redundant functional cast from 'Foo' to 'Foo' [loplugin:redundantfcast]}}
68 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */