Fixed #4227 (False positive: Comparison of a boolean with an integer (double dResult=false))
This commit is contained in:
parent
509721d6d0
commit
3372657a07
|
@ -6050,6 +6050,11 @@ bool Tokenizer::simplifyKnownVariablesGetData(unsigned int varid, Token **_tok2,
|
||||||
value += ".0";
|
value += ".0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// float variable: convert true/false to 1.0 / 0.0
|
||||||
|
else if (tok2->tokAt(2)->isBoolean() && floatvar) {
|
||||||
|
value = (value == "true") ? "1.0" : "0.0";
|
||||||
|
}
|
||||||
|
|
||||||
if (Token::simpleMatch(tok2->next(), "= &"))
|
if (Token::simpleMatch(tok2->next(), "= &"))
|
||||||
tok2 = tok2->tokAt(3);
|
tok2 = tok2->tokAt(3);
|
||||||
|
|
||||||
|
|
|
@ -2708,6 +2708,13 @@ private:
|
||||||
const char expected[] = "void f ( ) {\n\nx ( 0.25 ) ;\n}";
|
const char expected[] = "void f ( ) {\n\nx ( 0.25 ) ;\n}";
|
||||||
|
|
||||||
ASSERT_EQUALS(expected, tokenizeAndStringify(code,true));
|
ASSERT_EQUALS(expected, tokenizeAndStringify(code,true));
|
||||||
|
|
||||||
|
// Ticket #4227
|
||||||
|
const char code2[] = "double f() {"
|
||||||
|
" double a = false;"
|
||||||
|
" return a;"
|
||||||
|
"}";
|
||||||
|
ASSERT_EQUALS("double f ( ) { return 0.0 ; }", tokenizeAndStringify(code2,true));
|
||||||
}
|
}
|
||||||
|
|
||||||
void simplifyKnownVariablesFunctionCalls() {
|
void simplifyKnownVariablesFunctionCalls() {
|
||||||
|
|
Loading…
Reference in New Issue