Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / compilerplugins / clang / test / unusedvariablemore.cxx
blob712bcf403614e684f49ff844eef69ff715c9c900
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>
11 #include <sal/types.h>
12 #include <map>
14 struct SAL_WARN_UNUSED Point
17 struct SAL_WARN_UNUSED Rectangle
19 Rectangle();
20 Rectangle(int width, int height);
21 Rectangle& Union(const Rectangle&) { return *this; }
22 Rectangle& Intersection(const Rectangle&);
23 Rectangle& operator+=(const Point& rPt);
26 void func1()
28 Rectangle aTmp1; // expected-error {{unused variable 'aTmp1' [loplugin:unusedvariablemore]}}
29 aTmp1.Union(Rectangle(10, 10));
32 void func2()
34 Rectangle aViewArea(
35 10, 10); // expected-error@-1 {{unused variable 'aViewArea' [loplugin:unusedvariablemore]}}
36 aViewArea += Point();
37 aViewArea.Intersection(Rectangle(0, 0));
40 //---------------------------------------------------------------------
41 // Negative tests
42 //---------------------------------------------------------------------
44 Rectangle func3(const Rectangle& rRect)
46 Rectangle aTmpRect(Rectangle(10, 10));
47 return aTmpRect.Union(rRect);
50 void func4()
52 std::map<int, int> aMimeTypeMap;
53 aMimeTypeMap[1] = 0;
54 int aExportMimeType(aMimeTypeMap[0]);
55 (void)aExportMimeType;
58 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */