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>
14 #include <com/sun/star/uno/Reference.hxx>
15 #include <com/sun/star/uno/XInterface.hpp>
16 #include <rtl/ref.hxx>
17 #include <sal/types.h>
18 #include <tools/ref.hxx>
24 void function1(Struct1
& s
)
26 (&s
)->x
= 1; // expected-error {{'&' followed by '->' operating on 'Struct1', rather use '.' [loplugin:redundantpointerops]}}
31 Struct2
* operator&() { return this; }
34 void function2(Struct2 s
)
36 (&s
)->x
= 1; // expected-error {{'&' followed by '->' operating on 'Struct2', rather use '.' [loplugin:redundantpointerops]}}
39 void function3(Struct1
& s
)
41 (*(&s
)).x
= 1; // expected-error {{'&' followed by '*' operating on 'Struct1', rather use '.' [loplugin:redundantpointerops]}}
44 //void function4(Struct1* s)
46 // (*s).x = 1; // xxexpected-error {{'*' followed by '.', rather use '->' [loplugin:redundantpointerops]}}
49 int function5(std::unique_ptr
<int> x
)
51 return *x
.get(); // expected-error-re {{'*' followed by '.get()' operating on '{{.*}}unique_ptr{{.*}}', just use '*' [loplugin:redundantpointerops]}}
54 void function6(std::shared_ptr
<int> x
)
56 (void) *x
.get(); // expected-error-re {{'*' followed by '.get()' operating on '{{.*}}shared_ptr{{.*}}', just use '*' [loplugin:redundantpointerops]}}
59 void function6b(std::shared_ptr
<Struct1
> x
)
61 x
.get()->x
= 1; // expected-error-re {{'get()' followed by '->' operating on '{{.*}}shared_ptr{{.*}}', just use '->' [loplugin:redundantpointerops]}}
64 void function7(rtl::Reference
<css::uno::XInterface
> x
)
66 (void) *x
.get(); // expected-error {{'*' followed by '.get()' operating on 'rtl::Reference<css::uno::XInterface>', just use '*' [loplugin:redundantpointerops]}}
69 void function8(css::uno::Reference
<css::uno::XInterface
> x
)
71 (void) *x
.get(); // expected-error {{'*' followed by '.get()' operating on 'css::uno::Reference<css::uno::XInterface>', just use '*' [loplugin:redundantpointerops]}}
74 void function9(tools::SvRef
<SvRefBase
> x
)
76 (void) *x
.get(); // expected-error {{'*' followed by '.get()' operating on 'tools::SvRef<SvRefBase>', just use '*' [loplugin:redundantpointerops]}}
79 struct DerivedRtlReference
: public rtl::Reference
<css::uno::XInterface
> {};
81 void function10(DerivedRtlReference x
)
83 (void) *x
.get(); // expected-error {{'*' followed by '.get()' operating on 'DerivedRtlReference', just use '*' [loplugin:redundantpointerops]}}
86 struct DerivedUnoReference
: public css::uno::Reference
<css::uno::XInterface
> {};
88 void function11(DerivedUnoReference x
)
90 (void) *x
.get(); // expected-error {{'*' followed by '.get()' operating on 'DerivedUnoReference', just use '*' [loplugin:redundantpointerops]}}
93 // tools::SvRef is final
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */