Skip to content

Commit d42275c

Browse files
committed
Fixed TODO in checkAssignBoolToFloat
1 parent e6a394d commit d42275c

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎lib/checkbool.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,9 @@ void CheckBool::checkAssignBoolToFloat()
484484
for (std::size_t i = 0; i < functions; ++i) {
485485
const Scope * scope = symbolDatabase->functionScopes[i];
486486
for (const Token* tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) {
487-
if (Token::Match(tok, "!!* %var% = %bool% ;")) {
488-
const Variable * const var = symbolDatabase->getVariableFromVarId(tok->next()->varId());
489-
if (var && var->isFloatingType())
487+
if (Token::Match(tok, "%var% =")) {
488+
const Variable * const var = symbolDatabase->getVariableFromVarId(tok->varId());
489+
if (var && var->isFloatingType() && astIsBool(tok->next()->astOperand2()))
490490
assignBoolToFloatError(tok->next());
491491
}
492492
}

‎test/testbool.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class TestBool : public TestFixture {
154154
check("void foo3() {\n"
155155
" long double d = (2>1);\n"
156156
"}");
157-
TODO_ASSERT_EQUALS("[test.cpp:2]: (style) Boolean value assigned to floating point variable.\n", "", errout.str());
157+
ASSERT_EQUALS("[test.cpp:2]: (style) Boolean value assigned to floating point variable.\n", errout.str());
158158

159159
// stability - don't crash:
160160
check("void foo4() {\n"

0 commit comments

Comments
 (0)