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 <vcl/vclptr.hxx>
13 #include <vcl/vclreferencebase.hxx>
15 struct Widget
: public VclReferenceBase
17 VclPtr
<Widget
> mpParent
;
21 // test that we ignore assignments from a member field
24 // test against false+
25 p
= (true) ? mpParent
.get() : nullptr;
33 void dispose() override
36 VclReferenceBase::dispose();
50 // test the variable init detection
53 Widget
* p
= f(); // expected-error {{assigning a returned-by-value VclPtr<T> to a T* variable is dodgy, should be assigned to a VclPtr. If you know that the RHS does not return a newly created T, then add a '.get()' to the RHS [loplugin:vclwidgets]}}
61 // test the assignment detection
66 p
= f(); // expected-error {{assigning a returned-by-value VclPtr<T> to a T* variable is dodgy, should be assigned to a VclPtr. If you know that the RHS does not return a newly created T, then add a '.get()' to the RHS [loplugin:vclwidgets]}}
74 // test against false+
77 T
* get() { return nullptr; }
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */