From c0a34649c414f640f1fe994e2a7b73dfbdd387ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 14 Mar 2013 19:11:29 +0100 Subject: [PATCH] fixed 'duplicate expression' false positives for float-float. Ticket: #4639 --- lib/symboldatabase.cpp | 4 +++- test/testother.cpp | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index e5a04fc57..6fcbe93c7 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1045,7 +1045,9 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se if (Token::Match(second, "const %type% %var%|,|)")) 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 if (first->str() == ")") { return true; diff --git a/test/testother.cpp b/test/testother.cpp index 405a8a49d..40d961cab 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -173,6 +173,7 @@ private: TEST_CASE(duplicateExpression3); // ticket #3317 TEST_CASE(duplicateExpression4); // ticket #3354 (++) TEST_CASE(duplicateExpression5); // ticket #3749 (macros with same values) + TEST_CASE(duplicateExpression6); // ticket #4639 TEST_CASE(alwaysTrueFalseStringCompare); TEST_CASE(suspiciousStringCompare); @@ -5385,6 +5386,13 @@ private: 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() { check_preprocess_suppress( "#define MACRO \"00FF00\"\n"