fixed 'duplicate expression' false positives for float-float. Ticket: #4639

This commit is contained in:
Daniel Marjamäki 2013-03-14 19:11:29 +01:00
parent 369e80b021
commit c0a34649c4
2 changed files with 11 additions and 1 deletions

View File

@ -1045,7 +1045,9 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
if (Token::Match(second, "const %type% %var%|,|)")) if (Token::Match(second, "const %type% %var%|,|)"))
second = second->next(); second = second->next();
while (first->str() == second->str()) { while (first->str() == second->str() &&
first->isLong() == second->isLong() &&
first->isUnsigned() == second->isUnsigned()) {
// at end of argument list // at end of argument list
if (first->str() == ")") { if (first->str() == ")") {
return true; return true;

View File

@ -173,6 +173,7 @@ private:
TEST_CASE(duplicateExpression3); // ticket #3317 TEST_CASE(duplicateExpression3); // ticket #3317
TEST_CASE(duplicateExpression4); // ticket #3354 (++) TEST_CASE(duplicateExpression4); // ticket #3354 (++)
TEST_CASE(duplicateExpression5); // ticket #3749 (macros with same values) TEST_CASE(duplicateExpression5); // ticket #3749 (macros with same values)
TEST_CASE(duplicateExpression6); // ticket #4639
TEST_CASE(alwaysTrueFalseStringCompare); TEST_CASE(alwaysTrueFalseStringCompare);
TEST_CASE(suspiciousStringCompare); TEST_CASE(suspiciousStringCompare);
@ -5385,6 +5386,13 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void duplicateExpression6() { // #4639
check("float IsNan(float value) { return !(value == value); }\n"
"double IsNan(double value) { return !(value == value); }\n"
"long double IsNan(long double value) { return !(value == value); }\n");
ASSERT_EQUALS("", errout.str());
}
void alwaysTrueFalseStringCompare() { void alwaysTrueFalseStringCompare() {
check_preprocess_suppress( check_preprocess_suppress(
"#define MACRO \"00FF00\"\n" "#define MACRO \"00FF00\"\n"