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.
4 *
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 */
9
10 #include <sal/config.h>
11 #include <sal/types.h>
12 #include <map>
13
14 struct SAL_WARN_UNUSED Point
15 {
16 };
17 struct SAL_WARN_UNUSED Rectangle
18 {
19 Rectangle();
20 Rectangle(int width, int height);
UnionRectangle21 Rectangle& Union(const Rectangle&) { return *this; }
22 Rectangle& Intersection(const Rectangle&);
23 Rectangle& operator+=(const Point& rPt);
24 };
25
func1()26 void func1()
27 {
28 Rectangle aTmp1; // expected-error {{unused variable 'aTmp1' [loplugin:unusedvariablemore]}}
29 aTmp1.Union(Rectangle(10, 10));
30 }
31
func2()32 void func2()
33 {
34 Rectangle aViewArea(
35 10, 10); // expected-error@-1 {{unused variable 'aViewArea' [loplugin:unusedvariablemore]}}
36 aViewArea += Point();
37 aViewArea.Intersection(Rectangle(0, 0));
38 }
39
40 //---------------------------------------------------------------------
41 // Negative tests
42 //---------------------------------------------------------------------
43
func3(const Rectangle & rRect)44 Rectangle func3(const Rectangle& rRect)
45 {
46 Rectangle aTmpRect(Rectangle(10, 10));
47 return aTmpRect.Union(rRect);
48 }
49
func4()50 void func4()
51 {
52 std::map<int, int> aMimeTypeMap;
53 aMimeTypeMap[1] = 0;
54 int aExportMimeType(aMimeTypeMap[0]);
55 (void)aExportMimeType;
56 }
57
58 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
59