Skip to content

Commit 47cdc07

Browse files
firewavepfultz2
andcommitted
always calculate as float [skip ci]
Co-authored-by: Paul Fultz II <pfultz2@yahoo.com>
1 parent 443c6ff commit 47cdc07

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

lib/vf_settokenvalue.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,10 +558,11 @@ namespace ValueFlow
558558
break;
559559
}
560560
bool error = false;
561-
if (isFloat) {
562-
result.floatValue = calculate(parent->str(), floatValue1, floatValue2, &error);
561+
auto val = calculate(parent->str(), floatValue1, floatValue2, &error);
562+
if (result.isFloatValue()) {
563+
result.floatValue = val;
563564
} else {
564-
result.intvalue = calculate(parent->str(), intValue1(), intValue2(), &error);
565+
result.intvalue = val;
565566
}
566567
if (error)
567568
continue;

test/testcondition.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4465,11 +4465,9 @@ class TestCondition : public TestFixture {
44654465
" float f = 9.9f;\n"
44664466
" if(f < 10) {}\n"
44674467
"}\n");
4468-
TODO_ASSERT_EQUALS(
4468+
ASSERT_EQUALS(
44694469
"[test.cpp:3]: (style) Condition 'i>9.9' is always true\n"
44704470
"[test.cpp:5]: (style) Condition 'f<10' is always true\n",
4471-
"[test.cpp:3]: (style) Condition 'i>9.9' is always false\n"
4472-
"[test.cpp:5]: (style) Condition 'f<10' is always false\n",
44734471
errout_str());
44744472
check("constexpr int f() {\n" // #11238
44754473
" return 1;\n"
@@ -6284,11 +6282,9 @@ class TestCondition : public TestFixture {
62846282
" if (f > 9.9) {}\n"
62856283
" if (f < 9.9) {}\n"
62866284
"}\n");
6287-
TODO_ASSERT_EQUALS(
6285+
ASSERT_EQUALS(
62886286
"[test.cpp:3]: (style) Condition 'f>9.9' is always true\n"
62896287
"[test.cpp:4]: (style) Condition 'f<9.9' is always false\n",
6290-
"[test.cpp:3]: (style) Condition 'f>9.9' is always false\n"
6291-
"[test.cpp:4]: (style) Condition 'f<9.9' is always false\n",
62926288
errout_str());
62936289

62946290
check("void foo() {\n" // #12330

0 commit comments

Comments
 (0)