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 static const float PI
= 3.4;
13 float getFloat() const { return 1.5; }
14 int getInt() const { return 1; }
15 static constexpr float PI
= 3.4;
16 static constexpr float E() { return 3.4; }
19 void func1(Class1
const& class1
)
21 // expected-error@+1 {{comparing integer to float constant, can never be true [loplugin:intvsfloat]}}
24 // expected-error@+1 {{comparing integer to float constant, can never be true [loplugin:intvsfloat]}}
27 // expected-error@+1 {{comparing integer to float constant, can never be true [loplugin:intvsfloat]}}
28 if (true == class1
.PI
)
30 if (1 == class1
.getInt()) // no warning expected
32 // expected-error@+1 {{comparing integer to float constant, can never be true [loplugin:intvsfloat]}}
35 // expected-error@+1 {{comparing integer to float constant, can never be true [loplugin:intvsfloat]}}
36 if (true == class1
.E())
38 if (1 == class1
.getFloat()) // no warning expected
42 void func2(Class1
const& class1
)
44 // expected-error@+1 {{assigning constant float value to int truncates data [loplugin:intvsfloat]}}
47 // expected-error@+1 {{assigning constant float value to int truncates data [loplugin:intvsfloat]}}
50 // expected-error@+1 {{assigning constant float value to int truncates data [loplugin:intvsfloat]}}
53 int i3
= class1
.getFloat(); // no warning expected
55 int i4
= class1
.getInt(); // no warning expected
57 // expected-error@+1 {{assigning constant float value to int truncates data [loplugin:intvsfloat]}}
62 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */